status
stringclasses 1
value | repo_name
stringclasses 31
values | repo_url
stringclasses 31
values | issue_id
int64 1
104k
| title
stringlengths 4
233
| body
stringlengths 0
186k
⌀ | issue_url
stringlengths 38
56
| pull_url
stringlengths 37
54
| before_fix_sha
stringlengths 40
40
| after_fix_sha
stringlengths 40
40
| report_datetime
timestamp[us, tz=UTC] | language
stringclasses 5
values | commit_datetime
timestamp[us, tz=UTC] | updated_file
stringlengths 7
188
| chunk_content
stringlengths 1
1.03M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
cmd/dagger/cmd/do.go
|
var doCmd = &cobra.Command{
Use: "do ACTION [SUBACTION...]",
PreRun: func(cmd *cobra.Command, args []string) {
if err := viper.BindPFlags(cmd.Flags()); err != nil {
panic(err)
}
},
FParseErrWhitelist: cobra.FParseErrWhitelist{
UnknownFlags: true,
},
DisableFlagParsing: true,
Run: func(cmd *cobra.Command, args []string) {
cmd.Flags().Parse(args)
if err := viper.BindPFlags(cmd.Flags()); err != nil {
panic(err)
}
var (
lg = logger.New()
tty *logger.TTYOutput
ctx = lg.WithContext(cmd.Context())
)
switch !viper.GetBool("experimental") {
case len(viper.GetString("platform")) > 0:
lg.Fatal().Msg("--platform requires --experimental flag")
}
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
cmd/dagger/cmd/do.go
|
targetPath := getTargetPath(cmd.Flags().Args())
daggerPlan, err := loadPlan(ctx, viper.GetString("plan"))
if err != nil {
if viper.GetBool("help") {
doHelpCmd(cmd, nil, nil, nil, targetPath, nil)
os.Exit(0)
}
err = fmt.Errorf("failed to load plan: %w", err)
doHelpCmd(cmd, nil, nil, nil, targetPath, []string{err.Error()})
os.Exit(1)
}
action := daggerPlan.Action().FindByPath(targetPath)
if action == nil {
selectorStrs := []string{}
for _, selector := range targetPath.Selectors()[1:] {
selectorStrs = append(selectorStrs, selector.String())
}
targetStr := strings.Join(selectorStrs, " ")
err = fmt.Errorf("action not found: %s", targetStr)
action = daggerPlan.Action().FindClosest(targetPath)
if action == nil {
err = fmt.Errorf("no action found")
doHelpCmd(cmd, nil, nil, nil, targetPath, []string{err.Error()})
os.Exit(1)
}
targetPath = action.Path
doHelpCmd(cmd, daggerPlan, action, nil, action.Path, []string{err.Error()})
os.Exit(1)
}
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
cmd/dagger/cmd/do.go
|
actionFlags := getActionFlags(action)
actionFlags.Parse(args)
cmd.Flags().AddFlagSet(actionFlags)
if err != nil {
doHelpCmd(cmd, daggerPlan, action, actionFlags, targetPath, []string{err.Error()})
os.Exit(1)
}
if err := viper.BindPFlags(cmd.Flags()); err != nil {
panic(err)
}
if len(cmd.Flags().Args()) < 1 || viper.GetBool("help") {
doHelpCmd(cmd, daggerPlan, action, actionFlags, targetPath, []string{})
os.Exit(0)
}
if f := viper.GetString("log-format"); f == "tty" || f == "auto" && term.IsTerminal(int(os.Stdout.Fd())) {
tty, err = logger.NewTTYOutput(os.Stderr)
if err != nil {
lg.Fatal().Err(err).Msg("failed to initialize TTY logger")
}
tty.Start()
defer tty.Stop()
lg = lg.Output(tty)
ctx = lg.WithContext(ctx)
}
cl := common.NewClient(ctx)
actionFlags.VisitAll(func(flag *pflag.Flag) {
if cmd.Flags().Changed(flag.Name) {
fmt.Printf("Changed: %s: %s\n", flag.Name, cmd.Flags().Lookup(flag.Name).Value.String())
flagPath := []cue.Selector{}
flagPath = append(flagPath, targetPath.Selectors()...)
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
cmd/dagger/cmd/do.go
|
flagPath = append(flagPath, cue.Str(flag.Name))
daggerPlan.Source().FillPath(cue.MakePath(flagPath...), viper.Get(flag.Name))
}
})
doneCh := common.TrackCommand(ctx, cmd, &telemetry.Property{
Name: "action",
Value: targetPath.String(),
})
err = cl.Do(ctx, daggerPlan.Context(), func(ctx context.Context, s *solver.Solver) error {
return daggerPlan.Do(ctx, targetPath, s)
})
<-doneCh
daggerPlan.Context().TempDirs.Clean()
if err != nil {
lg.Fatal().Err(err).Msg("failed to execute plan")
}
format := viper.GetString("output-format")
file := viper.GetString("output")
if file != "" && tty != nil {
tty.Stop()
lg = logger.New()
}
action.UpdateFinal(daggerPlan.Final())
if err := plan.PrintOutputs(action.Outputs(), format, file); err != nil {
lg.Fatal().Err(err).Msg("failed to print action outputs")
}
},
}
func loadPlan(ctx context.Context, planPath string) (*plan.Plan, error) {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
cmd/dagger/cmd/do.go
|
absPlanPath, err := filepath.Abs(planPath)
if err != nil {
return nil, err
}
_, err = os.Stat(absPlanPath)
if err != nil {
return nil, err
}
return plan.Load(ctx, plan.Config{
Args: []string{planPath},
With: viper.GetStringSlice("with"),
})
}
func getTargetPath(args []string) cue.Path {
selectors := []cue.Selector{plan.ActionSelector}
for _, arg := range args {
selectors = append(selectors, cue.Str(arg))
}
return cue.MakePath(selectors...)
}
func doHelpCmd(cmd *cobra.Command, daggerPlan *plan.Plan, action *plan.Action, actionFlags *pflag.FlagSet, target cue.Path, preamble []string) {
lg := logger.New()
if len(preamble) > 0 {
fmt.Println(strings.Join(preamble, "\n"))
fmt.Println()
}
target = cue.MakePath(target.Selectors()[1:]...)
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
cmd/dagger/cmd/do.go
|
if action != nil {
selectorStrs := []string{}
for _, selector := range target.Selectors() {
selectorStrs = append(selectorStrs, selector.String())
}
targetStr := strings.Join(selectorStrs, " ")
fmt.Printf("Usage: \n dagger do %s [flags]\n\n", targetStr)
if actionFlags != nil {
fmt.Println("Options")
actionFlags.VisitAll(func(flag *pflag.Flag) {
flag.Hidden = false
})
fmt.Println(actionFlags.FlagUsages())
actionFlags.VisitAll(func(flag *pflag.Flag) {
flag.Hidden = true
})
}
} else {
fmt.Println("Usage: \n dagger do [flags]")
}
var err error
if daggerPlan != nil {
err = printActions(daggerPlan, action, os.Stdout, target)
}
fmt.Printf("\n%s", cmd.UsageString())
if err == nil {
lg.Fatal().Err(err)
}
}
func getActionFlags(action *plan.Action) *pflag.FlagSet {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
cmd/dagger/cmd/do.go
|
flags := pflag.NewFlagSet("action inputs", pflag.ContinueOnError)
flags.ParseErrorsWhitelist = pflag.ParseErrorsWhitelist{
UnknownFlags: true,
}
flags.Usage = func() {}
if action == nil {
panic("action is nil")
}
if action.Inputs() == nil {
panic("action inputs is nil")
}
for _, input := range action.Inputs() {
switch input.Type {
case "string":
flags.String(input.Name, "", input.Documentation)
case "int":
flags.Int(input.Name, 0, input.Documentation)
case "bool":
flags.Bool(input.Name, false, input.Documentation)
case "float":
flags.Float64(input.Name, 0, input.Documentation)
case "number":
flags.Float64(input.Name, 0, input.Documentation)
default:
}
flags.MarkHidden(input.Name)
}
return flags
}
func printActions(p *plan.Plan, action *plan.Action, w io.Writer, target cue.Path) error {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
cmd/dagger/cmd/do.go
|
if p == nil {
return nil
}
if action == nil {
return fmt.Errorf("action %s not found", target.String())
}
if len(action.Name) < 1 {
return nil
}
fmt.Printf("\nAvailable Actions:\n")
tw := tabwriter.NewWriter(w, 0, 0, 1, ' ', tabwriter.StripEscape)
defer tw.Flush()
for _, a := range action.Children {
if !a.Hidden {
lineParts := []string{"", a.Name, a.Documentation}
fmt.Fprintln(tw, strings.Join(lineParts, "\t"))
}
}
return nil
}
func init() {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
cmd/dagger/cmd/do.go
|
doCmd.Flags().StringArrayP("with", "w", []string{}, "")
doCmd.Flags().StringP("plan", "p", ".", "Path to plan (defaults to current directory)")
doCmd.Flags().Bool("no-cache", false, "Disable caching")
doCmd.Flags().String("platform", "", "Set target build platform (requires experimental)")
doCmd.Flags().String("output", "", "File path to write the action's output values. Prints to stdout if empty")
doCmd.Flags().String("output-format", "plain", "Format for output values (plain, json, yaml)")
doCmd.Flags().StringArray("cache-to", []string{},
"Cache export destinations (eg. user/app:cache, type=local,dest=path/to/dir)")
doCmd.Flags().StringArray("cache-from", []string{},
"External cache sources (eg. user/app:cache, type=local,src=path/to/dir)")
doCmd.SetUsageTemplate(`{{if .HasAvailableSubCommands}}
{{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}
Aliases:
{{.NameAndAliases}}{{end}}{{if .HasExample}}
Examples:
{{.Example}}{{end}}{{if .HasAvailableSubCommands}}
Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}
Flags:
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}
Global Flags:
{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}}
Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
{{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}}
Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}}
`)
}
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
cmd/dagger/logger/tty.go
|
package logger
import (
"bytes"
"encoding/json"
"fmt"
"io"
"os"
"strings"
"sync"
"time"
"unicode/utf8"
"github.com/containerd/console"
"github.com/morikuni/aec"
"github.com/tonistiigi/vt100"
"go.dagger.io/dagger/plan/task"
)
type Event map[string]interface{}
type Group struct {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
cmd/dagger/logger/tty.go
|
Name string
CurrentState task.State
FinalState task.State
Events []Event
Started *time.Time
Completed *time.Time
Members int
}
type Message struct {
Event Event
Group *Group
}
type Logs struct {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
cmd/dagger/logger/tty.go
|
Messages []Message
groups map[string]*Group
l sync.Mutex
}
func (l *Logs) Add(event Event) error {
l.l.Lock()
defer l.l.Unlock()
source := systemGroup
taskPath, ok := event["task"].(string)
if ok && len(taskPath) > 0 {
source = taskPath
} else if !ok {
l.Messages = append(l.Messages, Message{
Event: event,
})
return nil
}
groupKey := strings.Split(source, "._")[0]
group := l.groups[groupKey]
if group == nil {
now := time.Now()
group = &Group{
Name: groupKey,
Started: &now,
}
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
cmd/dagger/logger/tty.go
|
l.groups[groupKey] = group
l.Messages = append(l.Messages, Message{
Group: group,
})
}
if st, ok := event["state"].(string); ok {
t, err := task.ParseState(st)
if err != nil {
return err
}
if group.FinalState.CanTransition(t) {
group.FinalState = t
}
if t == task.StateComputing {
group.CurrentState = t
group.Members++
group.Completed = nil
} else {
group.Members--
if group.Members <= 0 {
now := time.Now()
group.Completed = &now
group.CurrentState = group.FinalState
}
}
return nil
}
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
cmd/dagger/logger/tty.go
|
group.Events = append(group.Events, event)
return nil
}
type TTYOutput struct {
cons console.Console
logs *Logs
lineCount int
l sync.RWMutex
stopCh chan struct{}
doneCh chan struct{}
printCh chan struct{}
}
func NewTTYOutput(w *os.File) (*TTYOutput, error) {
cons, err := console.ConsoleFromFile(w)
if err != nil {
return nil, err
}
c := &TTYOutput{
logs: &Logs{
groups: make(map[string]*Group),
},
cons: cons,
stopCh: make(chan struct{}),
doneCh: make(chan struct{}),
printCh: make(chan struct{}, 128),
}
return c, nil
}
func (c *TTYOutput) Start() {
defer close(c.doneCh)
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
cmd/dagger/logger/tty.go
|
go func() {
for {
select {
case <-c.stopCh:
return
case <-c.printCh:
c.print()
case <-time.After(100 * time.Millisecond):
c.print()
}
}
}()
}
func (c *TTYOutput) Stop() {
c.l.Lock()
defer c.l.Unlock()
if c.doneCh == nil {
return
}
close(c.stopCh)
<-c.doneCh
c.doneCh = nil
}
func (c *TTYOutput) Write(p []byte) (n int, err error) {
event := Event{}
d := json.NewDecoder(bytes.NewReader(p))
if err := d.Decode(&event); err != nil {
return n, fmt.Errorf("cannot decode event: %s", err)
}
if err := c.logs.Add(event); err != nil {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
cmd/dagger/logger/tty.go
|
return 0, err
}
c.print()
return len(p), nil
}
func (c *TTYOutput) print() {
c.l.Lock()
defer c.l.Unlock()
select {
case <-c.stopCh:
return
default:
}
width, height := c.getSize()
rint(c.cons, aec.Hide)
defer rint(c.cons, aec.Show)
b := aec.EmptyBuilder
for i := 0; i < c.lineCount; i++ {
b = b.Up(1)
}
rint(c.cons, b.ANSI)
linesPerGroup := c.linesPerGroup(width, height)
lineCount := 0
for _, e := range c.logs.Messages {
if group := e.Group; group != nil {
lineCount += c.printGroup(group, width, linesPerGroup)
} else {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
cmd/dagger/logger/tty.go
|
lineCount += c.printLine(c.cons, e.Event, width)
}
}
if diff := c.lineCount - lineCount; diff > 0 {
for i := 0; i < diff; i++ {
rintln(c.cons, strings.Repeat(" ", width))
}
rint(c.cons, aec.EmptyBuilder.Up(uint(diff)).Column(0).ANSI)
}
c.lineCount = lineCount
}
func (c *TTYOutput) linesPerGroup(width, height int) int {
usedLines := 0
for _, e := range c.logs.Messages {
if group := e.Group; group != nil {
usedLines++
continue
}
usedLines += c.printLine(io.Discard, e.Event, width)
}
runningGroups := 0
for _, e := range c.logs.Messages {
if group := e.Group; group != nil && group.CurrentState == task.StateComputing {
runningGroups++
}
}
linesPerGroup := 5
if freeLines := (height - usedLines); freeLines > 0 && runningGroups > 0 {
linesPerGroup = (freeLines - 2) / runningGroups
}
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
cmd/dagger/logger/tty.go
|
return linesPerGroup
}
func (c *TTYOutput) printLine(w io.Writer, event Event, width int) int {
e := colorize.Color(fmt.Sprintf("%s %s %s%s",
formatTimestamp(event),
formatLevel(event),
formatMessage(event),
formatFields(event),
))
ta := width - utf8.RuneCountInString(e); delta > 0 {
e += strings.Repeat(" ", delta)
}
e += "\n"
rint(w, e)
t := vt100.NewVT100(100, width)
t.Write([]byte(e))
return t.UsedHeight()
}
func (c *TTYOutput) printGroup(group *Group, width, maxLines int) int {
lineCount := 0
var out string
if group.Name != systemGroup {
prefix := ""
switch group.CurrentState {
case task.StateComputing:
prefix = "[+]"
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
cmd/dagger/logger/tty.go
|
case task.StateCanceled:
prefix = "[✗]"
case task.StateFailed:
prefix = "[✗]"
case task.StateCompleted:
prefix = "[✔]"
}
out = prefix + " " + group.Name
endTime := time.Now()
if group.Completed != nil {
endTime = *group.Completed
}
dt := endTime.Sub(*group.Started).Seconds()
if dt < 0.05 {
dt = 0
}
timer := fmt.Sprintf("%3.1fs", dt)
// align
out += strings.Repeat(" ", width-utf8.RuneCountInString(out)-len(timer))
out += timer
out += "\n"
// color
switch group.CurrentState {
case task.StateComputing:
out = aec.Apply(out, aec.LightBlueF)
case task.StateCanceled:
out = aec.Apply(out, aec.LightYellowF)
case task.StateFailed:
out = aec.Apply(out, aec.LightRedF)
case task.StateCompleted:
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
cmd/dagger/logger/tty.go
|
out = aec.Apply(out, aec.LightGreenF)
}
// Print
rint(c.cons, out)
lineCount++
}
printEvents := []Event{}
switch group.CurrentState {
case task.StateComputing:
printEvents = group.Events
// for computing tasks, show only last N
if len(printEvents) > maxLines && maxLines >= 0 {
printEvents = printEvents[len(printEvents)-maxLines:]
}
case task.StateCanceled:
// for completed tasks, don't show any logs
printEvents = []Event{}
case task.StateFailed:
// for failed, show all logs
printEvents = group.Events
case task.StateCompleted:
// for completed tasks, don't show any logs
printEvents = []Event{}
}
for _, event := range printEvents {
lineCount += c.printGroupLine(event, width)
}
return lineCount
}
func (c *TTYOutput) printGroupLine(event Event, width int) int {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
cmd/dagger/logger/tty.go
|
e := colorize.Color(fmt.Sprintf("%s%s",
formatMessage(event),
formatFields(event),
))
// trim
for utf8.RuneCountInString(e) > width {
e = e[0:len(e)-4] + "…"
}
ta := width - utf8.RuneCountInString(e); delta > 0 {
e += strings.Repeat(" ", delta)
}
e += "\n"
// color
e = aec.Apply(e, aec.Faint)
// Print
rint(c.cons, e)
return 1
}
func (c *TTYOutput) getSize() (int, int) {
width := 80
height := 10
size, err := c.cons.Size()
if err == nil && size.Width > 0 && size.Height > 0 {
width = int(size.Width)
height = int(size.Height)
}
return width, height
}
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
plan/plan.go
|
package plan
import (
"context"
"errors"
"fmt"
"strings"
"cuelang.org/go/cue"
cueflow "cuelang.org/go/tools/flow"
"github.com/rs/zerolog/log"
"go.dagger.io/dagger/compiler"
"go.dagger.io/dagger/pkg"
"go.dagger.io/dagger/plan/task"
"go.dagger.io/dagger/plancontext"
"go.dagger.io/dagger/solver"
"go.opentelemetry.io/otel"
)
var (
ErrIncompatiblePlan = errors.New("attempting to load a dagger 0.1.0 project.\nPlease upgrade your config to be compatible with this version of dagger. Contact the Dagger team if you need help")
ActionSelector = cue.Str("actions")
ClientSelector = cue.Str("client")
)
type Plan struct {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
plan/plan.go
|
config Config
context *plancontext.Context
source *compiler.Value
final *compiler.Value
action *Action
}
type Config struct {
Args []string
With []string
Target string
}
func Load(ctx context.Context, cfg Config) (*Plan, error) {
ctx, span := otel.Tracer("dagger").Start(ctx, "plan.Load")
defer span.End()
log.Ctx(ctx).Debug().Interface("args", cfg.Args).Msg("loading plan")
_, cueModExists := pkg.GetCueModParent()
if !cueModExists {
return nil, fmt.Errorf("dagger project not found. Run `dagger project init`")
}
if err := pkg.EnsureCompatibility(ctx, ""); err != nil {
return nil, err
}
v, err := compiler.Build(ctx, "", nil, cfg.Args...)
if err != nil {
errstring := err.Error()
if strings.Contains(errstring, "cannot find package") {
if strings.Contains(errstring, "alpha.dagger.io") {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
plan/plan.go
|
return nil, ErrIncompatiblePlan
} else if strings.Contains(errstring, pkg.DaggerModule) || strings.Contains(errstring, pkg.UniverseModule) {
return nil, fmt.Errorf("%w: running `dagger project update` may resolve this", err)
}
}
return nil, err
}
for i, param := range cfg.With {
log.Ctx(ctx).Debug().Interface("with", param).Msg("compiling overlay")
paramV, err := compiler.Compile(fmt.Sprintf("with%v", i), param)
if err != nil {
return nil, err
}
log.Ctx(ctx).Debug().Interface("with", param).Msg("filling overlay")
fillErr := v.FillPath(cue.MakePath(), paramV)
if fillErr != nil {
return nil, compiler.Err(fillErr)
}
}
p := &Plan{
config: cfg,
context: plancontext.New(),
source: v,
}
if err := p.validate(ctx); err != nil {
return nil, compiler.Err(err)
}
p.fillAction(ctx)
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
plan/plan.go
|
if err := p.prepare(ctx); err != nil {
return nil, err
}
return p, nil
}
func (p *Plan) Context() *plancontext.Context {
return p.context
}
func (p *Plan) Source() *compiler.Value {
return p.source
}
func (p *Plan) Final() *compiler.Value {
return p.final
}
func (p *Plan) Action() *Action {
return p.action
}
func (p *Plan) prepare(ctx context.Context) error {
_, span := otel.Tracer("dagger").Start(ctx, "plan.Prepare")
defer span.End()
flow := cueflow.New(
&cueflow.Config{
FindHiddenTasks: true,
},
p.source.Cue(),
func(flowVal cue.Value) (cueflow.Runner, error) {
v := compiler.Wrap(flowVal)
t, err := task.Lookup(v)
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
plan/plan.go
|
if err != nil {
if err == task.ErrNotTask {
return nil, nil
}
return nil, err
}
r, ok := t.(task.PreRunner)
if !ok {
return nil, nil
}
return cueflow.RunnerFunc(func(t *cueflow.Task) error {
ctx := t.Context()
lg := log.Ctx(ctx).With().Str("task", t.Path().String()).Logger()
ctx = lg.WithContext(ctx)
if err := r.PreRun(ctx, p.context, compiler.Wrap(t.Value())); err != nil {
return fmt.Errorf("%s: %w", t.Path().String(), err)
}
return nil
}), nil
},
)
return flow.Run(ctx)
}
func (p *Plan) Do(ctx context.Context, path cue.Path, s *solver.Solver) error {
ctx, span := otel.Tracer("dagger").Start(ctx, "plan.Do")
defer span.End()
r := NewRunner(p.context, path, s)
final, err := r.Run(ctx, p.source)
if err != nil {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
plan/plan.go
|
return err
}
p.final = final
return nil
}
func (p *Plan) fillAction(ctx context.Context) {
_, span := otel.Tracer("dagger").Start(ctx, "plan.FillAction")
defer span.End()
cfg := &cueflow.Config{
FindHiddenTasks: true,
Root: cue.MakePath(ActionSelector),
}
flow := cueflow.New(
cfg,
p.source.Cue(),
noOpRunner,
)
actionsPath := cue.MakePath(ActionSelector)
actions := p.source.LookupPath(actionsPath)
if !actions.Exists() {
return
}
p.action = &Action{
Name: ActionSelector.String(),
Documentation: actions.DocSummary(),
Hidden: false,
Path: actionsPath,
Children: []*Action{},
Value: p.Source().LookupPath(actionsPath),
}
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
plan/plan.go
|
tasks := flow.Tasks()
for _, t := range tasks {
var q []cue.Selector
prevAction := p.action
for _, s := range t.Path().Selectors() {
q = append(q, s)
path := cue.MakePath(q...)
a := prevAction.FindByPath(path)
if a == nil {
v := p.Source().LookupPath(path)
a = &Action{
Name: s.String(),
Hidden: s.PkgPath() != "",
Path: path,
Documentation: v.DocSummary(),
Children: []*Action{},
Value: v,
}
prevAction.AddChild(a)
}
prevAction = a
}
}
}
func (p *Plan) validate(ctx context.Context) error {
_, span := otel.Tracer("dagger").Start(ctx, "plan.Validate")
defer span.End()
return isPlanConcrete(p.source, p.source)
}
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
plan/runner.go
|
package plan
import (
"context"
"fmt"
"strings"
"sync"
"time"
"go.dagger.io/dagger/compiler"
"go.dagger.io/dagger/plan/task"
"go.dagger.io/dagger/plancontext"
"go.dagger.io/dagger/solver"
"cuelang.org/go/cue"
cueflow "cuelang.org/go/tools/flow"
"github.com/rs/zerolog/log"
"go.opentelemetry.io/otel"
)
type Runner struct {
pctx *plancontext.Context
target cue.Path
s *solver.Solver
tasks sync.Map
computed *compiler.Value
mirror *compiler.Value
l sync.Mutex
}
func NewRunner(pctx *plancontext.Context, target cue.Path, s *solver.Solver) *Runner {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
plan/runner.go
|
return &Runner{
pctx: pctx,
target: target,
s: s,
computed: compiler.NewValue(),
mirror: compiler.NewValue(),
}
}
func (r *Runner) Run(ctx context.Context, src *compiler.Value) (*compiler.Value, error) {
if !src.LookupPath(r.target).Exists() {
return nil, fmt.Errorf("%s not found", r.target.String())
}
if err := r.update(cue.MakePath(), src); err != nil {
return nil, err
}
flow := cueflow.New(
&cueflow.Config{
FindHiddenTasks: true,
},
src.Cue(),
r.taskFunc,
)
if err := flow.Run(ctx); err != nil {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
plan/runner.go
|
return nil, err
}
select {
case <-ctx.Done():
return nil, ctx.Err()
default:
if compSrc, err := r.computed.Source(); err == nil {
log.Ctx(ctx).Debug().Str("computed", string(compSrc)).Msg("computed values")
}
final := compiler.NewValue()
if err := final.FillPath(cue.MakePath(), src); err != nil {
return nil, err
}
if err := final.FillPath(cue.MakePath(), r.computed); err != nil {
return nil, err
}
return final, nil
}
}
func (r *Runner) update(p cue.Path, v *compiler.Value) error {
r.l.Lock()
defer r.l.Unlock()
if err := r.mirror.FillPath(p, v); err != nil {
return err
}
r.initTasks()
return nil
}
func (r *Runner) initTasks() {
flow := cueflow.New(
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
plan/runner.go
|
&cueflow.Config{
FindHiddenTasks: true,
},
r.mirror.Cue(),
noOpRunner,
)
for _, t := range flow.Tasks() {
if cuePathHasPrefix(t.Path(), r.target) {
r.addTask(t)
}
}
for _, t := range flow.Tasks() {
if t.Path().Selectors()[0] != ClientSelector {
continue
}
for _, dep := range t.Dependencies() {
if r.shouldRun(dep.Path()) {
r.addTask(t)
}
}
}
}
func (r *Runner) addTask(t *cueflow.Task) {
if _, ok := r.tasks.Load(t.Path().String()); ok {
return
}
r.tasks.Store(t.Path().String(), struct{}{})
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
plan/runner.go
|
for _, dep := range t.Dependencies() {
r.addTask(dep)
}
}
func (r *Runner) shouldRun(p cue.Path) bool {
_, ok := r.tasks.Load(p.String())
return ok
}
func (r *Runner) taskFunc(flowVal cue.Value) (cueflow.Runner, error) {
v := compiler.Wrap(flowVal)
handler, err := task.Lookup(v)
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
plan/runner.go
|
if err != nil {
if err == task.ErrNotTask {
return nil, nil
}
return nil, err
}
if !r.shouldRun(v.Path()) {
return nil, nil
}
return cueflow.RunnerFunc(func(t *cueflow.Task) error {
ctx := t.Context()
taskPath := t.Path().String()
lg := log.Ctx(ctx).With().Str("task", taskPath).Logger()
ctx = lg.WithContext(ctx)
ctx, span := otel.Tracer("dagger").Start(ctx, t.Path().String())
defer span.End()
lg.Info().Str("state", task.StateComputing.String()).Msg(task.StateComputing.String())
for _, dep := range t.Dependencies() {
lg.Debug().Str("dependency", dep.Path().String()).Msg("dependency detected")
}
start := time.Now()
result, err := handler.Run(ctx, r.pctx, r.s, compiler.Wrap(t.Value()))
if err != nil {
if strings.Contains(err.Error(), "context canceled") {
lg.Error().Dur("duration", time.Since(start)).Str("state", task.StateCanceled.String()).Msg(task.StateCanceled.String())
} else {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
plan/runner.go
|
lg.Error().Dur("duration", time.Since(start)).Err(compiler.Err(err)).Str("state", task.StateFailed.String()).Msg(task.StateFailed.String())
}
return fmt.Errorf("%s: %w", t.Path().String(), compiler.Err(err))
}
lg.Info().Dur("duration", time.Since(start)).Str("state", task.StateCompleted.String()).Msg(task.StateCompleted.String())
if !result.IsConcrete() {
return nil
}
if src, err := result.Source(); err == nil {
lg.Debug().Str("result", string(src)).Msg("merging task result")
}
if err := t.Fill(result.Cue()); err != nil {
lg.Error().Err(err).Msg("failed to fill task")
return err
}
if err := r.computed.FillPath(t.Path(), result); err != nil {
lg.Error().Err(err).Msg("failed to fill computed")
return err
}
return nil
}), nil
}
func cuePathHasPrefix(p cue.Path, prefix cue.Path) bool {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
plan/runner.go
|
pathSelectors := p.Selectors()
prefixSelectors := prefix.Selectors()
if len(pathSelectors) < len(prefixSelectors) {
return false
}
for i, sel := range prefixSelectors {
if pathSelectors[i] != sel {
return false
}
}
return true
}
func noOpRunner(flowVal cue.Value) (cueflow.Runner, error) {
v := compiler.Wrap(flowVal)
_, err := task.Lookup(v)
if err != nil {
if err == task.ErrNotTask {
return nil, nil
}
return nil, err
}
return cueflow.RunnerFunc(func(t *cueflow.Task) error {
return nil
}), nil
}
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
plan/task/task.go
|
package task
import (
"context"
"errors"
"fmt"
"sync"
"cuelang.org/go/cue"
"go.dagger.io/dagger/compiler"
"go.dagger.io/dagger/pkg"
"go.dagger.io/dagger/plancontext"
"go.dagger.io/dagger/solver"
)
var (
ErrNotTask = errors.New("not a task")
tasks sync.Map
typePath = cue.MakePath(
cue.Str("$dagger"),
cue.Str("task"),
cue.Hid("_name", pkg.DaggerPackage))
corePath = cue.MakePath(
cue.Str("$dagger"),
cue.Str("task"),
cue.Hid("_name", pkg.DaggerCorePackage))
paths = []cue.Path{corePath, typePath}
)
type State int8
func (s State) String() string {
return [...]string{"computing", "completed", "cancelled", "failed"}[s]
}
func ParseState(s string) (State, error) {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
plan/task/task.go
|
switch s {
case "computing":
return StateComputing, nil
case "cancelled":
return StateCanceled, nil
case "failed":
return StateFailed, nil
case "completed":
return StateCompleted, nil
}
return -1, fmt.Errorf("invalid state [%s]", s)
}
func (s State) CanTransition(t State) bool {
return s <= t
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
plan/task/task.go
|
}
const (
StateComputing State = iota
StateCompleted
StateCanceled
StateFailed
)
type NewFunc func() Task
type Task interface {
Run(ctx context.Context, pctx *plancontext.Context, s *solver.Solver, v *compiler.Value) (*compiler.Value, error)
}
type PreRunner interface {
Task
PreRun(ctx context.Context, pctx *plancontext.Context, v *compiler.Value) error
}
func Register(typ string, f NewFunc) {
tasks.Store(typ, f)
}
func New(typ string) Task {
v, ok := tasks.Load(typ)
if !ok {
return nil
}
fn := v.(NewFunc)
return fn()
}
func Lookup(v *compiler.Value) (Task, error) {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,299 |
`--help` suppressed plan loading errors
|
```console
$ dagger do -p ./plan/do/do_flags.cue test --help
Usage:
dagger do [flags]
```
vs
```console
$ dagger do -p ./plan/do/do_flags.cue test
failed to load plan: "actions.test.message" is not set:
./plan/do/do_flags.cue:21:3
./plan/do/do_flags.cue:25:4
Usage:
dagger do [flags]
```
|
https://github.com/dagger/dagger/issues/2299
|
https://github.com/dagger/dagger/pull/2378
|
453102b5f261c6e9d4b5d5bceee89a2aef55134f
|
9fb0313ab2aeb82bcd4367d7c8e4103a386fb873
| 2022-04-25T17:32:14Z |
go
| 2022-05-02T19:39:27Z |
plan/task/task.go
|
if v.Kind() != cue.StructKind {
return nil, ErrNotTask
}
typeString, err := lookupType(v)
if err != nil {
return nil, err
}
t := New(typeString)
if t == nil {
return nil, fmt.Errorf("unknown type %q", typeString)
}
return t, nil
}
func lookupType(v *compiler.Value) (string, error) {
for _, path := range paths {
typ := v.LookupPath(path)
if typ.Exists() {
return typ.String()
}
}
return "", ErrNotTask
}
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,297 |
🐞 Fix `dagger do` flag validation
|
### What is the issue?
https://github.com/dagger/dagger/pull/2261 broke flag validation for `dagger do` (while fixing another issue created by changing cobra flag parsing). We should work to enforce flag validation again.
### Log output
_No response_
### Steps to reproduce
_No response_
### Dagger version
dagger 0.2.7
### OS version
macOS 12.3
|
https://github.com/dagger/dagger/issues/2297
|
https://github.com/dagger/dagger/pull/2391
|
7039a1c985438a303e3f9696969d594d8f50188d
|
78da07d6cfccc7112b2b493c093ba047a1cd21af
| 2022-04-25T16:51:42Z |
go
| 2022-05-03T18:41:55Z |
cmd/dagger/cmd/do.go
|
package cmd
import (
"context"
"fmt"
"io"
"os"
"path/filepath"
"strings"
"text/tabwriter"
"cuelang.org/go/cue"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"go.dagger.io/dagger/cmd/dagger/cmd/common"
"go.dagger.io/dagger/cmd/dagger/logger"
"go.dagger.io/dagger/plan"
"go.dagger.io/dagger/solver"
"go.dagger.io/dagger/telemetry"
"golang.org/x/term"
)
var experimentalFlags = []string{
"platform",
"dry-run",
}
var doCmd = &cobra.Command{
Use: "do ACTION [SUBACTION...]",
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,297 |
🐞 Fix `dagger do` flag validation
|
### What is the issue?
https://github.com/dagger/dagger/pull/2261 broke flag validation for `dagger do` (while fixing another issue created by changing cobra flag parsing). We should work to enforce flag validation again.
### Log output
_No response_
### Steps to reproduce
_No response_
### Dagger version
dagger 0.2.7
### OS version
macOS 12.3
|
https://github.com/dagger/dagger/issues/2297
|
https://github.com/dagger/dagger/pull/2391
|
7039a1c985438a303e3f9696969d594d8f50188d
|
78da07d6cfccc7112b2b493c093ba047a1cd21af
| 2022-04-25T16:51:42Z |
go
| 2022-05-03T18:41:55Z |
cmd/dagger/cmd/do.go
|
PreRun: func(cmd *cobra.Command, args []string) {
if err := viper.BindPFlags(cmd.Flags()); err != nil {
panic(err)
}
},
FParseErrWhitelist: cobra.FParseErrWhitelist{
UnknownFlags: true,
},
DisableFlagParsing: true,
Run: func(cmd *cobra.Command, args []string) {
cmd.Flags().Parse(args)
if err := viper.BindPFlags(cmd.Flags()); err != nil {
panic(err)
}
var (
lg = logger.New()
tty *logger.TTYOutput
ctx = lg.WithContext(cmd.Context())
)
if !viper.GetBool("experimental") {
for _, f := range experimentalFlags {
if viper.IsSet(f) {
lg.Fatal().Msg(fmt.Sprintf("--%s requires --experimental flag", f))
}
}
}
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,297 |
🐞 Fix `dagger do` flag validation
|
### What is the issue?
https://github.com/dagger/dagger/pull/2261 broke flag validation for `dagger do` (while fixing another issue created by changing cobra flag parsing). We should work to enforce flag validation again.
### Log output
_No response_
### Steps to reproduce
_No response_
### Dagger version
dagger 0.2.7
### OS version
macOS 12.3
|
https://github.com/dagger/dagger/issues/2297
|
https://github.com/dagger/dagger/pull/2391
|
7039a1c985438a303e3f9696969d594d8f50188d
|
78da07d6cfccc7112b2b493c093ba047a1cd21af
| 2022-04-25T16:51:42Z |
go
| 2022-05-03T18:41:55Z |
cmd/dagger/cmd/do.go
|
targetPath := getTargetPath(cmd.Flags().Args())
daggerPlan, err := loadPlan(ctx, viper.GetString("plan"))
if err != nil {
if viper.GetBool("help") {
doHelpCmd(cmd, nil, nil, nil, targetPath, []string{err.Error()})
os.Exit(0)
}
err = fmt.Errorf("failed to load plan: %w", err)
doHelpCmd(cmd, nil, nil, nil, targetPath, []string{err.Error()})
os.Exit(1)
}
action := daggerPlan.Action().FindByPath(targetPath)
if action == nil {
selectorStrs := []string{}
for _, selector := range targetPath.Selectors()[1:] {
selectorStrs = append(selectorStrs, selector.String())
}
targetStr := strings.Join(selectorStrs, " ")
err = fmt.Errorf("action not found: %s", targetStr)
action = daggerPlan.Action().FindClosest(targetPath)
if action == nil {
err = fmt.Errorf("no action found")
doHelpCmd(cmd, nil, nil, nil, targetPath, []string{err.Error()})
os.Exit(1)
}
targetPath = action.Path
doHelpCmd(cmd, daggerPlan, action, nil, action.Path, []string{err.Error()})
os.Exit(1)
}
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,297 |
🐞 Fix `dagger do` flag validation
|
### What is the issue?
https://github.com/dagger/dagger/pull/2261 broke flag validation for `dagger do` (while fixing another issue created by changing cobra flag parsing). We should work to enforce flag validation again.
### Log output
_No response_
### Steps to reproduce
_No response_
### Dagger version
dagger 0.2.7
### OS version
macOS 12.3
|
https://github.com/dagger/dagger/issues/2297
|
https://github.com/dagger/dagger/pull/2391
|
7039a1c985438a303e3f9696969d594d8f50188d
|
78da07d6cfccc7112b2b493c093ba047a1cd21af
| 2022-04-25T16:51:42Z |
go
| 2022-05-03T18:41:55Z |
cmd/dagger/cmd/do.go
|
actionFlags := getActionFlags(action)
actionFlags.Parse(args)
cmd.Flags().AddFlagSet(actionFlags)
if err != nil {
doHelpCmd(cmd, daggerPlan, action, actionFlags, targetPath, []string{err.Error()})
os.Exit(1)
}
if err := viper.BindPFlags(cmd.Flags()); err != nil {
panic(err)
}
if len(cmd.Flags().Args()) < 1 || viper.GetBool("help") {
doHelpCmd(cmd, daggerPlan, action, actionFlags, targetPath, []string{})
os.Exit(0)
}
if f := viper.GetString("log-format"); f == "tty" || f == "auto" && term.IsTerminal(int(os.Stdout.Fd())) {
tty, err = logger.NewTTYOutput(os.Stderr)
if err != nil {
lg.Fatal().Err(err).Msg("failed to initialize TTY logger")
}
tty.Start()
defer tty.Stop()
lg = lg.Output(tty)
ctx = lg.WithContext(ctx)
}
cl := common.NewClient(ctx)
actionFlags.VisitAll(func(flag *pflag.Flag) {
if cmd.Flags().Changed(flag.Name) {
fmt.Printf("Changed: %s: %s\n", flag.Name, cmd.Flags().Lookup(flag.Name).Value.String())
flagPath := []cue.Selector{}
flagPath = append(flagPath, targetPath.Selectors()...)
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,297 |
🐞 Fix `dagger do` flag validation
|
### What is the issue?
https://github.com/dagger/dagger/pull/2261 broke flag validation for `dagger do` (while fixing another issue created by changing cobra flag parsing). We should work to enforce flag validation again.
### Log output
_No response_
### Steps to reproduce
_No response_
### Dagger version
dagger 0.2.7
### OS version
macOS 12.3
|
https://github.com/dagger/dagger/issues/2297
|
https://github.com/dagger/dagger/pull/2391
|
7039a1c985438a303e3f9696969d594d8f50188d
|
78da07d6cfccc7112b2b493c093ba047a1cd21af
| 2022-04-25T16:51:42Z |
go
| 2022-05-03T18:41:55Z |
cmd/dagger/cmd/do.go
|
flagPath = append(flagPath, cue.Str(flag.Name))
daggerPlan.Source().FillPath(cue.MakePath(flagPath...), viper.Get(flag.Name))
}
})
doneCh := common.TrackCommand(ctx, cmd, &telemetry.Property{
Name: "action",
Value: targetPath.String(),
})
err = cl.Do(ctx, daggerPlan.Context(), func(ctx context.Context, s *solver.Solver) error {
return daggerPlan.Do(ctx, targetPath, s)
})
<-doneCh
daggerPlan.Context().TempDirs.Clean()
if err != nil {
lg.Fatal().Err(err).Msg("failed to execute plan")
}
format := viper.GetString("output-format")
file := viper.GetString("output")
if file != "" && tty != nil {
tty.Stop()
lg = logger.New()
}
action.UpdateFinal(daggerPlan.Final())
if err := plan.PrintOutputs(action.Outputs(), format, file); err != nil {
lg.Fatal().Err(err).Msg("failed to print action outputs")
}
},
}
func loadPlan(ctx context.Context, planPath string) (*plan.Plan, error) {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,297 |
🐞 Fix `dagger do` flag validation
|
### What is the issue?
https://github.com/dagger/dagger/pull/2261 broke flag validation for `dagger do` (while fixing another issue created by changing cobra flag parsing). We should work to enforce flag validation again.
### Log output
_No response_
### Steps to reproduce
_No response_
### Dagger version
dagger 0.2.7
### OS version
macOS 12.3
|
https://github.com/dagger/dagger/issues/2297
|
https://github.com/dagger/dagger/pull/2391
|
7039a1c985438a303e3f9696969d594d8f50188d
|
78da07d6cfccc7112b2b493c093ba047a1cd21af
| 2022-04-25T16:51:42Z |
go
| 2022-05-03T18:41:55Z |
cmd/dagger/cmd/do.go
|
absPlanPath, err := filepath.Abs(planPath)
if err != nil {
return nil, err
}
_, err = os.Stat(absPlanPath)
if err != nil {
return nil, err
}
return plan.Load(ctx, plan.Config{
Args: []string{planPath},
With: viper.GetStringSlice("with"),
DryRun: viper.GetBool("dry-run"),
})
}
func getTargetPath(args []string) cue.Path {
selectors := []cue.Selector{plan.ActionSelector}
for _, arg := range args {
selectors = append(selectors, cue.Str(arg))
}
return cue.MakePath(selectors...)
}
func doHelpCmd(cmd *cobra.Command, daggerPlan *plan.Plan, action *plan.Action, actionFlags *pflag.FlagSet, target cue.Path, preamble []string) {
lg := logger.New()
if len(preamble) > 0 {
fmt.Println(strings.Join(preamble, "\n"))
fmt.Println()
}
target = cue.MakePath(target.Selectors()[1:]...)
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,297 |
🐞 Fix `dagger do` flag validation
|
### What is the issue?
https://github.com/dagger/dagger/pull/2261 broke flag validation for `dagger do` (while fixing another issue created by changing cobra flag parsing). We should work to enforce flag validation again.
### Log output
_No response_
### Steps to reproduce
_No response_
### Dagger version
dagger 0.2.7
### OS version
macOS 12.3
|
https://github.com/dagger/dagger/issues/2297
|
https://github.com/dagger/dagger/pull/2391
|
7039a1c985438a303e3f9696969d594d8f50188d
|
78da07d6cfccc7112b2b493c093ba047a1cd21af
| 2022-04-25T16:51:42Z |
go
| 2022-05-03T18:41:55Z |
cmd/dagger/cmd/do.go
|
if action != nil {
selectorStrs := []string{}
for _, selector := range target.Selectors() {
selectorStrs = append(selectorStrs, selector.String())
}
targetStr := strings.Join(selectorStrs, " ")
fmt.Printf("Usage: \n dagger do %s [flags]\n\n", targetStr)
if actionFlags != nil {
fmt.Println("Options")
actionFlags.VisitAll(func(flag *pflag.Flag) {
flag.Hidden = false
})
fmt.Println(actionFlags.FlagUsages())
actionFlags.VisitAll(func(flag *pflag.Flag) {
flag.Hidden = true
})
}
} else {
fmt.Println("Usage: \n dagger do [flags]")
}
var err error
if daggerPlan != nil {
err = printActions(daggerPlan, action, os.Stdout, target)
}
fmt.Printf("\n%s", cmd.UsageString())
if err == nil {
lg.Fatal().Err(err)
}
}
func getActionFlags(action *plan.Action) *pflag.FlagSet {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,297 |
🐞 Fix `dagger do` flag validation
|
### What is the issue?
https://github.com/dagger/dagger/pull/2261 broke flag validation for `dagger do` (while fixing another issue created by changing cobra flag parsing). We should work to enforce flag validation again.
### Log output
_No response_
### Steps to reproduce
_No response_
### Dagger version
dagger 0.2.7
### OS version
macOS 12.3
|
https://github.com/dagger/dagger/issues/2297
|
https://github.com/dagger/dagger/pull/2391
|
7039a1c985438a303e3f9696969d594d8f50188d
|
78da07d6cfccc7112b2b493c093ba047a1cd21af
| 2022-04-25T16:51:42Z |
go
| 2022-05-03T18:41:55Z |
cmd/dagger/cmd/do.go
|
flags := pflag.NewFlagSet("action inputs", pflag.ContinueOnError)
flags.ParseErrorsWhitelist = pflag.ParseErrorsWhitelist{
UnknownFlags: true,
}
flags.Usage = func() {}
if action == nil {
panic("action is nil")
}
if action.Inputs() == nil {
panic("action inputs is nil")
}
for _, input := range action.Inputs() {
switch input.Type {
case "string":
flags.String(input.Name, "", input.Documentation)
case "int":
flags.Int(input.Name, 0, input.Documentation)
case "bool":
flags.Bool(input.Name, false, input.Documentation)
case "float":
flags.Float64(input.Name, 0, input.Documentation)
case "number":
flags.Float64(input.Name, 0, input.Documentation)
default:
}
flags.MarkHidden(input.Name)
}
return flags
}
func printActions(p *plan.Plan, action *plan.Action, w io.Writer, target cue.Path) error {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,297 |
🐞 Fix `dagger do` flag validation
|
### What is the issue?
https://github.com/dagger/dagger/pull/2261 broke flag validation for `dagger do` (while fixing another issue created by changing cobra flag parsing). We should work to enforce flag validation again.
### Log output
_No response_
### Steps to reproduce
_No response_
### Dagger version
dagger 0.2.7
### OS version
macOS 12.3
|
https://github.com/dagger/dagger/issues/2297
|
https://github.com/dagger/dagger/pull/2391
|
7039a1c985438a303e3f9696969d594d8f50188d
|
78da07d6cfccc7112b2b493c093ba047a1cd21af
| 2022-04-25T16:51:42Z |
go
| 2022-05-03T18:41:55Z |
cmd/dagger/cmd/do.go
|
if p == nil {
return nil
}
if action == nil {
return fmt.Errorf("action %s not found", target.String())
}
if len(action.Name) < 1 {
return nil
}
fmt.Printf("\nAvailable Actions:\n")
tw := tabwriter.NewWriter(w, 0, 0, 1, ' ', tabwriter.StripEscape)
defer tw.Flush()
for _, a := range action.Children {
if !a.Hidden {
lineParts := []string{"", a.Name, a.Documentation}
fmt.Fprintln(tw, strings.Join(lineParts, "\t"))
}
}
return nil
}
func init() {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,297 |
🐞 Fix `dagger do` flag validation
|
### What is the issue?
https://github.com/dagger/dagger/pull/2261 broke flag validation for `dagger do` (while fixing another issue created by changing cobra flag parsing). We should work to enforce flag validation again.
### Log output
_No response_
### Steps to reproduce
_No response_
### Dagger version
dagger 0.2.7
### OS version
macOS 12.3
|
https://github.com/dagger/dagger/issues/2297
|
https://github.com/dagger/dagger/pull/2391
|
7039a1c985438a303e3f9696969d594d8f50188d
|
78da07d6cfccc7112b2b493c093ba047a1cd21af
| 2022-04-25T16:51:42Z |
go
| 2022-05-03T18:41:55Z |
cmd/dagger/cmd/do.go
|
doCmd.Flags().StringArrayP("with", "w", []string{}, "")
doCmd.Flags().StringP("plan", "p", ".", "Path to plan (defaults to current directory)")
doCmd.Flags().Bool("dry-run", false, "Dry run mode")
doCmd.Flags().Bool("no-cache", false, "Disable caching")
doCmd.Flags().String("platform", "", "Set target build platform (requires experimental)")
doCmd.Flags().String("output", "", "File path to write the action's output values. Prints to stdout if empty")
doCmd.Flags().String("output-format", "plain", "Format for output values (plain, json, yaml)")
doCmd.Flags().StringArray("cache-to", []string{},
"Cache export destinations (eg. user/app:cache, type=local,dest=path/to/dir)")
doCmd.Flags().StringArray("cache-from", []string{},
"External cache sources (eg. user/app:cache, type=local,src=path/to/dir)")
doCmd.SetUsageTemplate(`{{if .HasAvailableSubCommands}}
{{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}
Aliases:
{{.NameAndAliases}}{{end}}{{if .HasExample}}
Examples:
{{.Example}}{{end}}{{if .HasAvailableSubCommands}}
Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}
Flags:
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}
Global Flags:
{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}}
Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
{{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}}
Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}}
`)
}
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,413 |
Make sure project update is handling built-ins and external dependencies
|
Looking at the code, it appears that `dagger project update` is only vendoring the built-in packages, not making sure the external packages are installed.
As a first step on #2163, we should at least make sure that there's consistency in the `project update` command in regards to built-ins and external dependencies because we're already documenting its usage like this.
|
https://github.com/dagger/dagger/issues/2413
|
https://github.com/dagger/dagger/pull/2423
|
2a679b59c878c5505132bb8f9243658e3303f95c
|
ed9255e51d3125e2675ffbd24b75b31aea3dc2dc
| 2022-05-06T22:50:51Z |
go
| 2022-05-12T09:55:51Z |
cmd/dagger/cmd/project/update.go
|
package project
import (
"fmt"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"go.dagger.io/dagger/cmd/dagger/cmd/common"
"go.dagger.io/dagger/cmd/dagger/logger"
"go.dagger.io/dagger/mod"
"go.dagger.io/dagger/pkg"
)
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,413 |
Make sure project update is handling built-ins and external dependencies
|
Looking at the code, it appears that `dagger project update` is only vendoring the built-in packages, not making sure the external packages are installed.
As a first step on #2163, we should at least make sure that there's consistency in the `project update` command in regards to built-ins and external dependencies because we're already documenting its usage like this.
|
https://github.com/dagger/dagger/issues/2413
|
https://github.com/dagger/dagger/pull/2423
|
2a679b59c878c5505132bb8f9243658e3303f95c
|
ed9255e51d3125e2675ffbd24b75b31aea3dc2dc
| 2022-05-06T22:50:51Z |
go
| 2022-05-12T09:55:51Z |
cmd/dagger/cmd/project/update.go
|
var updateCmd = &cobra.Command{
Use: "update [package]",
Short: "Download and install dependencies",
Args: cobra.MaximumNArgs(1),
PreRun: func(cmd *cobra.Command, args []string) {
if err := viper.BindPFlags(cmd.Flags()); err != nil {
panic(err)
}
},
Run: func(cmd *cobra.Command, args []string) {
lg := logger.New()
ctx := lg.WithContext(cmd.Context())
var err error
cueModPath, cueModExists := pkg.GetCueModParent()
if !cueModExists {
lg.Fatal().Msg("dagger project not found. Run `dagger project init`")
}
if len(args) == 0 {
lg.Debug().Msg("No package specified, updating all packages")
pkg.Vendor(ctx, cueModPath)
fmt.Println("Project updated")
return
}
var update = viper.GetBool("update")
doneCh := common.TrackCommand(ctx, cmd)
var processedRequires []*mod.Require
if update && len(args) == 0 {
lg.Info().Msg("updating all installed packages...")
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,413 |
Make sure project update is handling built-ins and external dependencies
|
Looking at the code, it appears that `dagger project update` is only vendoring the built-in packages, not making sure the external packages are installed.
As a first step on #2163, we should at least make sure that there's consistency in the `project update` command in regards to built-ins and external dependencies because we're already documenting its usage like this.
|
https://github.com/dagger/dagger/issues/2413
|
https://github.com/dagger/dagger/pull/2423
|
2a679b59c878c5505132bb8f9243658e3303f95c
|
ed9255e51d3125e2675ffbd24b75b31aea3dc2dc
| 2022-05-06T22:50:51Z |
go
| 2022-05-12T09:55:51Z |
cmd/dagger/cmd/project/update.go
|
processedRequires, err = mod.UpdateInstalled(ctx, cueModPath)
} else if update && len(args) > 0 {
lg.Info().Msg("updating specified packages...")
processedRequires, err = mod.UpdateAll(ctx, cueModPath, args)
} else if !update && len(args) > 0 {
lg.Info().Msg("installing specified packages...")
processedRequires, err = mod.InstallAll(ctx, cueModPath, args)
} else {
lg.Fatal().Msg("unrecognized update/install operation")
}
if len(processedRequires) > 0 {
for _, r := range processedRequires {
lg.Info().Msgf("installed/updated package %s", r)
}
}
<-doneCh
if err != nil {
lg.Error().Err(err).Msg("error installing/updating packages")
}
},
}
func init() {
updateCmd.Flags().String("private-key-file", "", "Private ssh key")
updateCmd.Flags().String("private-key-password", "", "Private ssh key password")
updateCmd.Flags().BoolP("update", "u", false, "Update specified package")
if err := viper.BindPFlags(updateCmd.Flags()); err != nil {
panic(err)
}
}
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,413 |
Make sure project update is handling built-ins and external dependencies
|
Looking at the code, it appears that `dagger project update` is only vendoring the built-in packages, not making sure the external packages are installed.
As a first step on #2163, we should at least make sure that there's consistency in the `project update` command in regards to built-ins and external dependencies because we're already documenting its usage like this.
|
https://github.com/dagger/dagger/issues/2413
|
https://github.com/dagger/dagger/pull/2423
|
2a679b59c878c5505132bb8f9243658e3303f95c
|
ed9255e51d3125e2675ffbd24b75b31aea3dc2dc
| 2022-05-06T22:50:51Z |
go
| 2022-05-12T09:55:51Z |
mod/file.go
|
package mod
import (
"bytes"
"context"
"errors"
"fmt"
"io"
"io/fs"
"io/ioutil"
"os"
"path"
"regexp"
"strings"
"github.com/spf13/viper"
)
const (
modFilePath = "./cue.mod/dagger.mod"
sumFilePath = "./cue.mod/dagger.sum"
lockFilePath = "./cue.mod/dagger.lock"
destBasePath = "./cue.mod/pkg"
tmpBasePath = "./cue.mod/tmp"
)
type file struct {
requires []*Require
workspacePath string
}
func readPath(workspacePath string) (*file, error) {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,413 |
Make sure project update is handling built-ins and external dependencies
|
Looking at the code, it appears that `dagger project update` is only vendoring the built-in packages, not making sure the external packages are installed.
As a first step on #2163, we should at least make sure that there's consistency in the `project update` command in regards to built-ins and external dependencies because we're already documenting its usage like this.
|
https://github.com/dagger/dagger/issues/2413
|
https://github.com/dagger/dagger/pull/2423
|
2a679b59c878c5505132bb8f9243658e3303f95c
|
ed9255e51d3125e2675ffbd24b75b31aea3dc2dc
| 2022-05-06T22:50:51Z |
go
| 2022-05-12T09:55:51Z |
mod/file.go
|
pMod := path.Join(workspacePath, modFilePath)
fMod, err := os.Open(pMod)
if err != nil {
if !errors.Is(err, fs.ErrNotExist) {
return nil, err
}
if fMod, err = os.Create(pMod); err != nil {
return nil, err
}
}
pSum := path.Join(workspacePath, sumFilePath)
fSum, err := os.Open(pSum)
if err != nil {
if !errors.Is(err, fs.ErrNotExist) {
return nil, err
}
if fSum, err = os.Create(pSum); err != nil {
return nil, err
}
}
modFile, err := read(fMod, fSum)
if err != nil {
return nil, err
}
modFile.workspacePath = workspacePath
return modFile, nil
}
func read(fMod, fSum io.Reader) (*file, error) {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,413 |
Make sure project update is handling built-ins and external dependencies
|
Looking at the code, it appears that `dagger project update` is only vendoring the built-in packages, not making sure the external packages are installed.
As a first step on #2163, we should at least make sure that there's consistency in the `project update` command in regards to built-ins and external dependencies because we're already documenting its usage like this.
|
https://github.com/dagger/dagger/issues/2413
|
https://github.com/dagger/dagger/pull/2423
|
2a679b59c878c5505132bb8f9243658e3303f95c
|
ed9255e51d3125e2675ffbd24b75b31aea3dc2dc
| 2022-05-06T22:50:51Z |
go
| 2022-05-12T09:55:51Z |
mod/file.go
|
bMod, err := ioutil.ReadAll(fMod)
if err != nil {
return nil, err
}
bSum, err := ioutil.ReadAll(fSum)
if err != nil {
return nil, err
}
modLines := nonEmptyLines(bMod)
sumLines := nonEmptyLines(bSum)
if len(modLines) != len(sumLines) {
return nil, fmt.Errorf("length of dagger.mod and dagger.sum files differ")
}
requires := make([]*Require, 0, len(modLines))
for i := 0; i < len(modLines); i++ {
modSplit := strings.Split(modLines[i], " ")
if len(modSplit) != 2 {
return nil, fmt.Errorf("line in the mod file doesn't contain 2 elements")
}
sumSplit := strings.Split(sumLines[i], " ")
if len(sumSplit) != 2 {
return nil, fmt.Errorf("line in the sum file doesn't contain 2 elements")
}
if modSplit[0] != sumSplit[0] {
return nil, fmt.Errorf("repos in mod and sum line don't match: %s and %s", modSplit[0], sumSplit[0])
}
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,413 |
Make sure project update is handling built-ins and external dependencies
|
Looking at the code, it appears that `dagger project update` is only vendoring the built-in packages, not making sure the external packages are installed.
As a first step on #2163, we should at least make sure that there's consistency in the `project update` command in regards to built-ins and external dependencies because we're already documenting its usage like this.
|
https://github.com/dagger/dagger/issues/2413
|
https://github.com/dagger/dagger/pull/2423
|
2a679b59c878c5505132bb8f9243658e3303f95c
|
ed9255e51d3125e2675ffbd24b75b31aea3dc2dc
| 2022-05-06T22:50:51Z |
go
| 2022-05-12T09:55:51Z |
mod/file.go
|
require, err := newRequire(modSplit[0], "")
if err != nil {
return nil, err
}
require.version = modSplit[1]
require.checksum = sumSplit[1]
requires = append(requires, require)
}
return &file{requires: requires}, nil
}
var spaceRgx = regexp.MustCompile(`\s+`)
func nonEmptyLines(b []byte) []string {
s := strings.ReplaceAll(string(b), "\r\n", "\n")
split := strings.Split(s, "\n")
lines := make([]string, 0, len(split))
for _, l := range split {
trimmed := strings.TrimSpace(l)
if trimmed == "" {
continue
}
trimmed = spaceRgx.ReplaceAllString(trimmed, " ")
lines = append(lines, trimmed)
}
return lines
}
func (f *file) install(ctx context.Context, req *Require) error {
tmpPath := path.Join(f.workspacePath, tmpBasePath, req.fullPath())
defer os.RemoveAll(tmpPath)
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,413 |
Make sure project update is handling built-ins and external dependencies
|
Looking at the code, it appears that `dagger project update` is only vendoring the built-in packages, not making sure the external packages are installed.
As a first step on #2163, we should at least make sure that there's consistency in the `project update` command in regards to built-ins and external dependencies because we're already documenting its usage like this.
|
https://github.com/dagger/dagger/issues/2413
|
https://github.com/dagger/dagger/pull/2423
|
2a679b59c878c5505132bb8f9243658e3303f95c
|
ed9255e51d3125e2675ffbd24b75b31aea3dc2dc
| 2022-05-06T22:50:51Z |
go
| 2022-05-12T09:55:51Z |
mod/file.go
|
r, err := clone(ctx, req, tmpPath, viper.GetString("private-key-file"), viper.GetString("private-key-password"))
if err != nil {
return fmt.Errorf("error downloading package %s: %w", req, err)
}
destPath := path.Join(f.workspacePath, destBasePath, req.fullPath())
existing := f.searchInstalledRequire(req)
if existing == nil {
if err = replace(req, tmpPath, destPath); err != nil {
return err
}
checksum, err := dirChecksum(destPath)
if err != nil {
return err
}
req.checksum = checksum
f.requires = append(f.requires, req)
return nil
}
existing.version = req.version
if err = r.checkout(ctx, req.version); err != nil {
return err
}
if err = replace(req, tmpPath, destPath); err != nil {
return err
}
checksum, err := dirChecksum(destPath)
if err != nil {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,413 |
Make sure project update is handling built-ins and external dependencies
|
Looking at the code, it appears that `dagger project update` is only vendoring the built-in packages, not making sure the external packages are installed.
As a first step on #2163, we should at least make sure that there's consistency in the `project update` command in regards to built-ins and external dependencies because we're already documenting its usage like this.
|
https://github.com/dagger/dagger/issues/2413
|
https://github.com/dagger/dagger/pull/2423
|
2a679b59c878c5505132bb8f9243658e3303f95c
|
ed9255e51d3125e2675ffbd24b75b31aea3dc2dc
| 2022-05-06T22:50:51Z |
go
| 2022-05-12T09:55:51Z |
mod/file.go
|
return err
}
existing.checksum = checksum
return nil
}
func (f *file) updateToLatest(ctx context.Context, req *Require) (*Require, error) {
existing := f.searchInstalledRequire(req)
if existing == nil {
return nil, fmt.Errorf("package %s isn't already installed", req.fullPath())
}
tmpPath := path.Join(f.workspacePath, tmpBasePath, existing.fullPath())
defer os.RemoveAll(tmpPath)
gitRepo, err := clone(ctx, existing, tmpPath, viper.GetString("private-key-file"), viper.GetString("private-key-password"))
if err != nil {
return nil, fmt.Errorf("error downloading package %s: %w", existing, err)
}
latestTag, err := gitRepo.latestTag(ctx, req.versionConstraint)
if err != nil {
return nil, err
}
c, err := compareVersions(latestTag, existing.version)
if err != nil {
return nil, err
}
if c < 0 {
return nil, fmt.Errorf("latest git tag is less than the current version")
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,413 |
Make sure project update is handling built-ins and external dependencies
|
Looking at the code, it appears that `dagger project update` is only vendoring the built-in packages, not making sure the external packages are installed.
As a first step on #2163, we should at least make sure that there's consistency in the `project update` command in regards to built-ins and external dependencies because we're already documenting its usage like this.
|
https://github.com/dagger/dagger/issues/2413
|
https://github.com/dagger/dagger/pull/2423
|
2a679b59c878c5505132bb8f9243658e3303f95c
|
ed9255e51d3125e2675ffbd24b75b31aea3dc2dc
| 2022-05-06T22:50:51Z |
go
| 2022-05-12T09:55:51Z |
mod/file.go
|
}
existing.version = latestTag
if err = gitRepo.checkout(ctx, existing.version); err != nil {
return nil, err
}
destPath := path.Join(f.workspacePath, destBasePath, existing.fullPath())
if err = replace(existing, tmpPath, destPath); err != nil {
return nil, err
}
checksum, err := dirChecksum(destPath)
if err != nil {
return nil, err
}
req.checksum = checksum
return existing, nil
}
func (f *file) searchInstalledRequire(r *Require) *Require {
for _, existing := range f.requires {
if existing.fullPath() == r.fullPath() {
return existing
}
}
return nil
}
func (f *file) ensure() error {
for _, require := range f.requires {
requirePath := path.Join(f.workspacePath, destBasePath, require.fullPath())
checksum, err := dirChecksum(requirePath)
if err != nil {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,413 |
Make sure project update is handling built-ins and external dependencies
|
Looking at the code, it appears that `dagger project update` is only vendoring the built-in packages, not making sure the external packages are installed.
As a first step on #2163, we should at least make sure that there's consistency in the `project update` command in regards to built-ins and external dependencies because we're already documenting its usage like this.
|
https://github.com/dagger/dagger/issues/2413
|
https://github.com/dagger/dagger/pull/2423
|
2a679b59c878c5505132bb8f9243658e3303f95c
|
ed9255e51d3125e2675ffbd24b75b31aea3dc2dc
| 2022-05-06T22:50:51Z |
go
| 2022-05-12T09:55:51Z |
mod/file.go
|
return nil
}
if require.checksum != checksum {
return fmt.Errorf("wrong checksum for %s", require.fullPath())
}
}
return nil
}
func (f *file) write() error {
var bMod bytes.Buffer
for _, r := range f.requires {
bMod.WriteString(fmt.Sprintf("%s %s\n", r.fullPath(), r.version))
}
err := ioutil.WriteFile(path.Join(f.workspacePath, modFilePath), bMod.Bytes(), 0600)
if err != nil {
return err
}
var bSum bytes.Buffer
for _, r := range f.requires {
bSum.WriteString(fmt.Sprintf("%s %s\n", r.fullPath(), r.checksum))
}
err = ioutil.WriteFile(path.Join(f.workspacePath, sumFilePath), bSum.Bytes(), 0600)
if err != nil {
return err
}
return nil
}
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,413 |
Make sure project update is handling built-ins and external dependencies
|
Looking at the code, it appears that `dagger project update` is only vendoring the built-in packages, not making sure the external packages are installed.
As a first step on #2163, we should at least make sure that there's consistency in the `project update` command in regards to built-ins and external dependencies because we're already documenting its usage like this.
|
https://github.com/dagger/dagger/issues/2413
|
https://github.com/dagger/dagger/pull/2423
|
2a679b59c878c5505132bb8f9243658e3303f95c
|
ed9255e51d3125e2675ffbd24b75b31aea3dc2dc
| 2022-05-06T22:50:51Z |
go
| 2022-05-12T09:55:51Z |
mod/mod.go
|
package mod
import (
"context"
"fmt"
"os"
"path"
"strings"
"github.com/gofrs/flock"
"github.com/rs/zerolog/log"
"go.dagger.io/dagger/pkg"
)
const (
UniverseVersionConstraint = ">= 0.1.0, < 0.2"
)
func isUniverse(repoName string) bool {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,413 |
Make sure project update is handling built-ins and external dependencies
|
Looking at the code, it appears that `dagger project update` is only vendoring the built-in packages, not making sure the external packages are installed.
As a first step on #2163, we should at least make sure that there's consistency in the `project update` command in regards to built-ins and external dependencies because we're already documenting its usage like this.
|
https://github.com/dagger/dagger/issues/2413
|
https://github.com/dagger/dagger/pull/2423
|
2a679b59c878c5505132bb8f9243658e3303f95c
|
ed9255e51d3125e2675ffbd24b75b31aea3dc2dc
| 2022-05-06T22:50:51Z |
go
| 2022-05-12T09:55:51Z |
mod/mod.go
|
return strings.HasPrefix(strings.ToLower(repoName), pkg.UniverseModule)
}
func IsUniverseLatest(ctx context.Context, workspace string) (bool, error) {
modfile, err := readPath(workspace)
if err != nil {
return false, err
}
req, err := newRequire(pkg.UniverseModule, UniverseVersionConstraint)
if err != nil {
return false, err
}
universe := modfile.searchInstalledRequire(req)
if universe == nil {
return false, fmt.Errorf("universe not installed")
}
tmpPath := path.Join(modfile.workspacePath, tmpBasePath, req.fullPath())
defer os.RemoveAll(tmpPath)
repo, err := clone(ctx, req, tmpPath, "", "")
if err != nil {
return false, err
}
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,413 |
Make sure project update is handling built-ins and external dependencies
|
Looking at the code, it appears that `dagger project update` is only vendoring the built-in packages, not making sure the external packages are installed.
As a first step on #2163, we should at least make sure that there's consistency in the `project update` command in regards to built-ins and external dependencies because we're already documenting its usage like this.
|
https://github.com/dagger/dagger/issues/2413
|
https://github.com/dagger/dagger/pull/2423
|
2a679b59c878c5505132bb8f9243658e3303f95c
|
ed9255e51d3125e2675ffbd24b75b31aea3dc2dc
| 2022-05-06T22:50:51Z |
go
| 2022-05-12T09:55:51Z |
mod/mod.go
|
latestTag, err := repo.latestTag(ctx, req.versionConstraint)
if err != nil {
return false, err
}
c, err := compareVersions(latestTag, universe.version)
if err != nil {
return false, err
}
return !(c == 1), nil
}
func Install(ctx context.Context, workspace, repoName, versionConstraint string) (*Require, error) {
lg := log.Ctx(ctx)
if isUniverse(repoName) {
versionConstraint = UniverseVersionConstraint
}
lg.Debug().Str("name", repoName).Msg("installing module")
require, err := newRequire(repoName, versionConstraint)
if err != nil {
return nil, err
}
modfile, err := readPath(workspace)
if err != nil {
return nil, err
}
fileLockPath := path.Join(workspace, lockFilePath)
fileLock := flock.New(fileLockPath)
if err := fileLock.Lock(); err != nil {
return nil, err
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,413 |
Make sure project update is handling built-ins and external dependencies
|
Looking at the code, it appears that `dagger project update` is only vendoring the built-in packages, not making sure the external packages are installed.
As a first step on #2163, we should at least make sure that there's consistency in the `project update` command in regards to built-ins and external dependencies because we're already documenting its usage like this.
|
https://github.com/dagger/dagger/issues/2413
|
https://github.com/dagger/dagger/pull/2423
|
2a679b59c878c5505132bb8f9243658e3303f95c
|
ed9255e51d3125e2675ffbd24b75b31aea3dc2dc
| 2022-05-06T22:50:51Z |
go
| 2022-05-12T09:55:51Z |
mod/mod.go
|
}
defer func() {
fileLock.Unlock()
os.Remove(fileLockPath)
}()
err = modfile.install(ctx, require)
if err != nil {
return nil, err
}
if err = modfile.write(); err != nil {
return nil, err
}
return require, nil
}
func InstallAll(ctx context.Context, workspace string, repoNames []string) ([]*Require, error) {
installedRequires := make([]*Require, 0, len(repoNames))
var err error
for _, repoName := range repoNames {
var require *Require
if require, err = Install(ctx, workspace, repoName, ""); err != nil {
continue
}
installedRequires = append(installedRequires, require)
}
return installedRequires, err
}
func Update(ctx context.Context, workspace, repoName, versionConstraint string) (*Require, error) {
lg := log.Ctx(ctx)
if isUniverse(repoName) {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,413 |
Make sure project update is handling built-ins and external dependencies
|
Looking at the code, it appears that `dagger project update` is only vendoring the built-in packages, not making sure the external packages are installed.
As a first step on #2163, we should at least make sure that there's consistency in the `project update` command in regards to built-ins and external dependencies because we're already documenting its usage like this.
|
https://github.com/dagger/dagger/issues/2413
|
https://github.com/dagger/dagger/pull/2423
|
2a679b59c878c5505132bb8f9243658e3303f95c
|
ed9255e51d3125e2675ffbd24b75b31aea3dc2dc
| 2022-05-06T22:50:51Z |
go
| 2022-05-12T09:55:51Z |
mod/mod.go
|
versionConstraint = UniverseVersionConstraint
}
lg.Debug().Str("name", repoName).Msg("updating module")
require, err := newRequire(repoName, versionConstraint)
if err != nil {
return nil, err
}
modfile, err := readPath(workspace)
if err != nil {
return nil, err
}
fileLockPath := path.Join(workspace, lockFilePath)
fileLock := flock.New(fileLockPath)
if err := fileLock.Lock(); err != nil {
return nil, err
}
defer func() {
fileLock.Unlock()
os.Remove(fileLockPath)
}()
updatedRequire, err := modfile.updateToLatest(ctx, require)
if err != nil {
return nil, err
}
if err = modfile.write(); err != nil {
return nil, err
}
return updatedRequire, nil
}
func UpdateAll(ctx context.Context, workspace string, repoNames []string) ([]*Require, error) {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,413 |
Make sure project update is handling built-ins and external dependencies
|
Looking at the code, it appears that `dagger project update` is only vendoring the built-in packages, not making sure the external packages are installed.
As a first step on #2163, we should at least make sure that there's consistency in the `project update` command in regards to built-ins and external dependencies because we're already documenting its usage like this.
|
https://github.com/dagger/dagger/issues/2413
|
https://github.com/dagger/dagger/pull/2423
|
2a679b59c878c5505132bb8f9243658e3303f95c
|
ed9255e51d3125e2675ffbd24b75b31aea3dc2dc
| 2022-05-06T22:50:51Z |
go
| 2022-05-12T09:55:51Z |
mod/mod.go
|
updatedRequires := make([]*Require, 0, len(repoNames))
var err error
for _, repoName := range repoNames {
var require *Require
if require, err = Update(ctx, workspace, repoName, ""); err != nil {
continue
}
updatedRequires = append(updatedRequires, require)
}
return updatedRequires, err
}
func UpdateInstalled(ctx context.Context, workspace string) ([]*Require, error) {
modfile, err := readPath(workspace)
if err != nil {
return nil, err
}
repoNames := make([]string, 0, len(modfile.requires))
for _, require := range modfile.requires {
repoNames = append(repoNames, require.String())
}
return UpdateAll(ctx, workspace, repoNames)
}
func Ensure(workspace string) error {
modfile, err := readPath(workspace)
if err != nil {
return err
}
return modfile.ensure()
}
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,413 |
Make sure project update is handling built-ins and external dependencies
|
Looking at the code, it appears that `dagger project update` is only vendoring the built-in packages, not making sure the external packages are installed.
As a first step on #2163, we should at least make sure that there's consistency in the `project update` command in regards to built-ins and external dependencies because we're already documenting its usage like this.
|
https://github.com/dagger/dagger/issues/2413
|
https://github.com/dagger/dagger/pull/2423
|
2a679b59c878c5505132bb8f9243658e3303f95c
|
ed9255e51d3125e2675ffbd24b75b31aea3dc2dc
| 2022-05-06T22:50:51Z |
go
| 2022-05-12T09:55:51Z |
mod/require.go
|
package mod
import (
"fmt"
"os"
"path"
"path/filepath"
"regexp"
"strings"
"go.dagger.io/dagger/pkg"
)
type Require struct {
repo string
path string
cloneRepo string
clonePath string
version string
versionConstraint string
checksum string
}
func newRequire(repoName, versionConstraint string) (*Require, error) {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,413 |
Make sure project update is handling built-ins and external dependencies
|
Looking at the code, it appears that `dagger project update` is only vendoring the built-in packages, not making sure the external packages are installed.
As a first step on #2163, we should at least make sure that there's consistency in the `project update` command in regards to built-ins and external dependencies because we're already documenting its usage like this.
|
https://github.com/dagger/dagger/issues/2413
|
https://github.com/dagger/dagger/pull/2423
|
2a679b59c878c5505132bb8f9243658e3303f95c
|
ed9255e51d3125e2675ffbd24b75b31aea3dc2dc
| 2022-05-06T22:50:51Z |
go
| 2022-05-12T09:55:51Z |
mod/require.go
|
switch {
case strings.HasPrefix(repoName, pkg.UniverseModule):
return parseDaggerRepoName(repoName, versionConstraint)
default:
return parseGitRepoName(repoName, versionConstraint)
}
}
var gitRepoNameRegex = regexp.MustCompile(`([a-zA-Z0-9_.-]+(?::\d*)?/[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+)([a-zA-Z0-9/_.-]*)@?([0-9a-zA-Z.-]*)`)
func parseGitRepoName(repoName, versionConstraint string) (*Require, error) {
repoMatches := gitRepoNameRegex.FindStringSubmatch(repoName)
if len(repoMatches) < 4 {
return nil, fmt.Errorf("issue when parsing github repo")
}
return &Require{
repo: strings.TrimSuffix(repoMatches[1], ".git"),
path: repoMatches[2],
version: repoMatches[3],
versionConstraint: versionConstraint,
cloneRepo: repoMatches[1],
clonePath: repoMatches[2],
}, nil
}
var daggerRepoNameRegex = regexp.MustCompile(pkg.UniverseModule + `([a-zA-Z0-9/_.-]*)@?([0-9a-zA-Z.-]*)`)
func parseDaggerRepoName(repoName, versionConstraint string) (*Require, error) {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,413 |
Make sure project update is handling built-ins and external dependencies
|
Looking at the code, it appears that `dagger project update` is only vendoring the built-in packages, not making sure the external packages are installed.
As a first step on #2163, we should at least make sure that there's consistency in the `project update` command in regards to built-ins and external dependencies because we're already documenting its usage like this.
|
https://github.com/dagger/dagger/issues/2413
|
https://github.com/dagger/dagger/pull/2423
|
2a679b59c878c5505132bb8f9243658e3303f95c
|
ed9255e51d3125e2675ffbd24b75b31aea3dc2dc
| 2022-05-06T22:50:51Z |
go
| 2022-05-12T09:55:51Z |
mod/require.go
|
repoMatches := daggerRepoNameRegex.FindStringSubmatch(repoName)
if len(repoMatches) < 3 {
return nil, fmt.Errorf("issue when parsing dagger repo")
}
return &Require{
repo: pkg.UniverseModule,
path: repoMatches[1],
version: repoMatches[2],
versionConstraint: versionConstraint,
cloneRepo: "github.com/dagger/examples",
clonePath: path.Join("/helloapp", repoMatches[1]),
}, nil
}
func (r *Require) String() string {
return fmt.Sprintf("%s@%s", r.fullPath(), r.version)
}
func (r *Require) fullPath() string {
return path.Join(r.repo, r.path)
}
func replace(r *Require, sourceRepoPath, destPath string) error {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,413 |
Make sure project update is handling built-ins and external dependencies
|
Looking at the code, it appears that `dagger project update` is only vendoring the built-in packages, not making sure the external packages are installed.
As a first step on #2163, we should at least make sure that there's consistency in the `project update` command in regards to built-ins and external dependencies because we're already documenting its usage like this.
|
https://github.com/dagger/dagger/issues/2413
|
https://github.com/dagger/dagger/pull/2423
|
2a679b59c878c5505132bb8f9243658e3303f95c
|
ed9255e51d3125e2675ffbd24b75b31aea3dc2dc
| 2022-05-06T22:50:51Z |
go
| 2022-05-12T09:55:51Z |
mod/require.go
|
if err := os.RemoveAll(destPath); err != nil {
return err
}
if err := os.MkdirAll(filepath.Dir(destPath), 0755); err != nil {
return err
}
if err := os.Rename(path.Join(sourceRepoPath, r.clonePath), destPath); err != nil {
return err
}
return nil
}
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,474 |
Output format should be json when stdout is not tty
|
`dagger do` prints the actions' outputs on standard output.
If I want to pipe the outputs to a tool, like `jq`, I need to explicitly set the output format to json with `--output-format json`. But that format should be the default when I am piping the output. This is already what we do for logging: log format defaults to json when output is not a tty.
|
https://github.com/dagger/dagger/issues/2474
|
https://github.com/dagger/dagger/pull/2487
|
9e4b0551936d5c9689065ce5e22eb18cc7088f19
|
9ee0a85e6ed190a3868e0c3eba82a373ebb62823
| 2022-05-18T17:54:08Z |
go
| 2022-05-20T01:23:40Z |
cmd/dagger/cmd/do.go
|
package cmd
import (
"context"
"fmt"
"io"
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,474 |
Output format should be json when stdout is not tty
|
`dagger do` prints the actions' outputs on standard output.
If I want to pipe the outputs to a tool, like `jq`, I need to explicitly set the output format to json with `--output-format json`. But that format should be the default when I am piping the output. This is already what we do for logging: log format defaults to json when output is not a tty.
|
https://github.com/dagger/dagger/issues/2474
|
https://github.com/dagger/dagger/pull/2487
|
9e4b0551936d5c9689065ce5e22eb18cc7088f19
|
9ee0a85e6ed190a3868e0c3eba82a373ebb62823
| 2022-05-18T17:54:08Z |
go
| 2022-05-20T01:23:40Z |
cmd/dagger/cmd/do.go
|
"os"
"path/filepath"
"strings"
"text/tabwriter"
"cuelang.org/go/cue"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/spf13/viper"
"go.dagger.io/dagger/analytics"
"go.dagger.io/dagger/cmd/dagger/cmd/common"
"go.dagger.io/dagger/cmd/dagger/logger"
"go.dagger.io/dagger/plan"
"go.dagger.io/dagger/solver"
"golang.org/x/term"
)
var experimentalFlags = []string{
"platform",
"dry-run",
}
var doCmd = &cobra.Command{
Use: "do ACTION [SUBACTION...]",
PreRun: func(cmd *cobra.Command, args []string) {
if err := viper.BindPFlags(cmd.Flags()); err != nil {
panic(err)
}
},
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,474 |
Output format should be json when stdout is not tty
|
`dagger do` prints the actions' outputs on standard output.
If I want to pipe the outputs to a tool, like `jq`, I need to explicitly set the output format to json with `--output-format json`. But that format should be the default when I am piping the output. This is already what we do for logging: log format defaults to json when output is not a tty.
|
https://github.com/dagger/dagger/issues/2474
|
https://github.com/dagger/dagger/pull/2487
|
9e4b0551936d5c9689065ce5e22eb18cc7088f19
|
9ee0a85e6ed190a3868e0c3eba82a373ebb62823
| 2022-05-18T17:54:08Z |
go
| 2022-05-20T01:23:40Z |
cmd/dagger/cmd/do.go
|
FParseErrWhitelist: cobra.FParseErrWhitelist{
UnknownFlags: true,
},
DisableFlagParsing: true,
Run: func(cmd *cobra.Command, args []string) {
cmd.Flags().Parse(args)
if err := viper.BindPFlags(cmd.Flags()); err != nil {
panic(err)
}
var (
lg = logger.New()
tty *logger.TTYOutput
ctx = lg.WithContext(cmd.Context())
)
if !viper.GetBool("experimental") {
for _, f := range experimentalFlags {
if viper.IsSet(f) {
lg.Fatal().Msg(fmt.Sprintf("--%s requires --experimental flag", f))
}
}
}
targetPath := getTargetPath(cmd.Flags().Args())
daggerPlan, err := loadPlan(ctx, viper.GetString("plan"))
if err != nil {
if viper.GetBool("help") {
doHelpCmd(cmd, nil, nil, nil, targetPath, []string{err.Error()})
os.Exit(0)
}
err = fmt.Errorf("failed to load plan: %w", err)
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,474 |
Output format should be json when stdout is not tty
|
`dagger do` prints the actions' outputs on standard output.
If I want to pipe the outputs to a tool, like `jq`, I need to explicitly set the output format to json with `--output-format json`. But that format should be the default when I am piping the output. This is already what we do for logging: log format defaults to json when output is not a tty.
|
https://github.com/dagger/dagger/issues/2474
|
https://github.com/dagger/dagger/pull/2487
|
9e4b0551936d5c9689065ce5e22eb18cc7088f19
|
9ee0a85e6ed190a3868e0c3eba82a373ebb62823
| 2022-05-18T17:54:08Z |
go
| 2022-05-20T01:23:40Z |
cmd/dagger/cmd/do.go
|
doHelpCmd(cmd, nil, nil, nil, targetPath, []string{err.Error()})
os.Exit(1)
}
action := daggerPlan.Action().FindByPath(targetPath)
if action == nil {
selectorStrs := []string{}
for _, selector := range targetPath.Selectors()[1:] {
selectorStrs = append(selectorStrs, selector.String())
}
targetStr := strings.Join(selectorStrs, " ")
err = fmt.Errorf("action not found: %s", targetStr)
action = daggerPlan.Action().FindClosest(targetPath)
if action == nil {
err = fmt.Errorf("no action found")
doHelpCmd(cmd, nil, nil, nil, targetPath, []string{err.Error()})
os.Exit(1)
}
targetPath = action.Path
doHelpCmd(cmd, daggerPlan, action, nil, action.Path, []string{err.Error()})
os.Exit(1)
}
actionFlags := getActionFlags(action)
cmd.Flags().AddFlagSet(actionFlags)
cmd.Flags().VisitAll(func(f *pflag.Flag) {
if v, ok := f.Value.(pflag.SliceValue); ok {
v.Replace([]string{})
}
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,474 |
Output format should be json when stdout is not tty
|
`dagger do` prints the actions' outputs on standard output.
If I want to pipe the outputs to a tool, like `jq`, I need to explicitly set the output format to json with `--output-format json`. But that format should be the default when I am piping the output. This is already what we do for logging: log format defaults to json when output is not a tty.
|
https://github.com/dagger/dagger/issues/2474
|
https://github.com/dagger/dagger/pull/2487
|
9e4b0551936d5c9689065ce5e22eb18cc7088f19
|
9ee0a85e6ed190a3868e0c3eba82a373ebb62823
| 2022-05-18T17:54:08Z |
go
| 2022-05-20T01:23:40Z |
cmd/dagger/cmd/do.go
|
})
err = cmd.Flags().Parse(args)
if err != nil {
doHelpCmd(cmd, daggerPlan, action, actionFlags, targetPath, []string{err.Error()})
os.Exit(1)
}
lg.Debug().Msgf("viper flags %#v", viper.AllSettings())
if err := viper.BindPFlags(cmd.Flags()); err != nil {
panic(err)
}
if len(cmd.Flags().Args()) < 1 || viper.GetBool("help") {
doHelpCmd(cmd, daggerPlan, action, actionFlags, targetPath, []string{})
os.Exit(0)
}
if f := viper.GetString("log-format"); f == "tty" || f == "auto" && term.IsTerminal(int(os.Stdout.Fd())) {
tty, err = logger.NewTTYOutput(os.Stderr)
if err != nil {
lg.Fatal().Err(err).Msg("failed to initialize TTY logger")
}
tty.Start()
defer tty.Stop()
lg = lg.Output(tty)
ctx = lg.WithContext(ctx)
}
cl := common.NewClient(ctx)
actionFlags.VisitAll(func(flag *pflag.Flag) {
if cmd.Flags().Changed(flag.Name) {
fmt.Printf("Changed: %s: %s\n", flag.Name, cmd.Flags().Lookup(flag.Name).Value.String())
flagPath := []cue.Selector{}
flagPath = append(flagPath, targetPath.Selectors()...)
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,474 |
Output format should be json when stdout is not tty
|
`dagger do` prints the actions' outputs on standard output.
If I want to pipe the outputs to a tool, like `jq`, I need to explicitly set the output format to json with `--output-format json`. But that format should be the default when I am piping the output. This is already what we do for logging: log format defaults to json when output is not a tty.
|
https://github.com/dagger/dagger/issues/2474
|
https://github.com/dagger/dagger/pull/2487
|
9e4b0551936d5c9689065ce5e22eb18cc7088f19
|
9ee0a85e6ed190a3868e0c3eba82a373ebb62823
| 2022-05-18T17:54:08Z |
go
| 2022-05-20T01:23:40Z |
cmd/dagger/cmd/do.go
|
flagPath = append(flagPath, cue.Str(flag.Name))
daggerPlan.Source().FillPath(cue.MakePath(flagPath...), viper.Get(flag.Name))
}
})
doneCh := common.TrackCommand(ctx, cmd, &analytics.Property{
Name: "action",
Value: targetPath.String(),
})
err = cl.Do(ctx, daggerPlan.Context(), func(ctx context.Context, s *solver.Solver) error {
return daggerPlan.Do(ctx, targetPath, s)
})
<-doneCh
daggerPlan.Context().TempDirs.Clean()
if err != nil {
lg.Fatal().Err(err).Msg("failed to execute plan")
}
format := viper.GetString("output-format")
file := viper.GetString("output")
if file != "" && tty != nil {
tty.Stop()
lg = logger.New()
}
action.UpdateFinal(daggerPlan.Final())
if err := plan.PrintOutputs(action.Outputs(), format, file); err != nil {
lg.Fatal().Err(err).Msg("failed to print action outputs")
}
},
}
func loadPlan(ctx context.Context, planPath string) (*plan.Plan, error) {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,474 |
Output format should be json when stdout is not tty
|
`dagger do` prints the actions' outputs on standard output.
If I want to pipe the outputs to a tool, like `jq`, I need to explicitly set the output format to json with `--output-format json`. But that format should be the default when I am piping the output. This is already what we do for logging: log format defaults to json when output is not a tty.
|
https://github.com/dagger/dagger/issues/2474
|
https://github.com/dagger/dagger/pull/2487
|
9e4b0551936d5c9689065ce5e22eb18cc7088f19
|
9ee0a85e6ed190a3868e0c3eba82a373ebb62823
| 2022-05-18T17:54:08Z |
go
| 2022-05-20T01:23:40Z |
cmd/dagger/cmd/do.go
|
absPlanPath, err := filepath.Abs(planPath)
if err != nil {
return nil, err
}
_, err = os.Stat(absPlanPath)
if err != nil {
return nil, err
}
return plan.Load(ctx, plan.Config{
Args: []string{planPath},
With: viper.GetStringSlice("with"),
DryRun: viper.GetBool("dry-run"),
})
}
func getTargetPath(args []string) cue.Path {
selectors := []cue.Selector{plan.ActionSelector}
for _, arg := range args {
selectors = append(selectors, cue.Str(arg))
}
return cue.MakePath(selectors...)
}
func doHelpCmd(cmd *cobra.Command, daggerPlan *plan.Plan, action *plan.Action, actionFlags *pflag.FlagSet, target cue.Path, preamble []string) {
lg := logger.New()
if len(preamble) > 0 {
fmt.Println(strings.Join(preamble, "\n"))
fmt.Println()
}
target = cue.MakePath(target.Selectors()[1:]...)
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,474 |
Output format should be json when stdout is not tty
|
`dagger do` prints the actions' outputs on standard output.
If I want to pipe the outputs to a tool, like `jq`, I need to explicitly set the output format to json with `--output-format json`. But that format should be the default when I am piping the output. This is already what we do for logging: log format defaults to json when output is not a tty.
|
https://github.com/dagger/dagger/issues/2474
|
https://github.com/dagger/dagger/pull/2487
|
9e4b0551936d5c9689065ce5e22eb18cc7088f19
|
9ee0a85e6ed190a3868e0c3eba82a373ebb62823
| 2022-05-18T17:54:08Z |
go
| 2022-05-20T01:23:40Z |
cmd/dagger/cmd/do.go
|
if action != nil {
selectorStrs := []string{}
for _, selector := range target.Selectors() {
selectorStrs = append(selectorStrs, selector.String())
}
targetStr := strings.Join(selectorStrs, " ")
fmt.Printf("Usage: \n dagger do %s [flags]\n\n", targetStr)
if actionFlags != nil {
fmt.Println("Options")
actionFlags.VisitAll(func(flag *pflag.Flag) {
flag.Hidden = false
})
fmt.Println(actionFlags.FlagUsages())
actionFlags.VisitAll(func(flag *pflag.Flag) {
flag.Hidden = true
})
}
} else {
fmt.Println("Usage: \n dagger do [flags]")
}
var err error
if daggerPlan != nil {
err = printActions(daggerPlan, action, os.Stdout, target)
}
fmt.Printf("\n%s", cmd.UsageString())
if err == nil {
lg.Fatal().Err(err)
}
}
func getActionFlags(action *plan.Action) *pflag.FlagSet {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,474 |
Output format should be json when stdout is not tty
|
`dagger do` prints the actions' outputs on standard output.
If I want to pipe the outputs to a tool, like `jq`, I need to explicitly set the output format to json with `--output-format json`. But that format should be the default when I am piping the output. This is already what we do for logging: log format defaults to json when output is not a tty.
|
https://github.com/dagger/dagger/issues/2474
|
https://github.com/dagger/dagger/pull/2487
|
9e4b0551936d5c9689065ce5e22eb18cc7088f19
|
9ee0a85e6ed190a3868e0c3eba82a373ebb62823
| 2022-05-18T17:54:08Z |
go
| 2022-05-20T01:23:40Z |
cmd/dagger/cmd/do.go
|
flags := pflag.NewFlagSet("action inputs", pflag.ContinueOnError)
flags.ParseErrorsWhitelist = pflag.ParseErrorsWhitelist{
UnknownFlags: true,
}
flags.Usage = func() {}
if action == nil {
panic("action is nil")
}
if action.Inputs() == nil {
panic("action inputs is nil")
}
for _, input := range action.Inputs() {
switch input.Type {
case "string":
flags.String(input.Name, "", input.Documentation)
case "int":
flags.Int(input.Name, 0, input.Documentation)
case "bool":
flags.Bool(input.Name, false, input.Documentation)
case "float":
flags.Float64(input.Name, 0, input.Documentation)
case "number":
flags.Float64(input.Name, 0, input.Documentation)
default:
}
flags.MarkHidden(input.Name)
}
return flags
}
func printActions(p *plan.Plan, action *plan.Action, w io.Writer, target cue.Path) error {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,474 |
Output format should be json when stdout is not tty
|
`dagger do` prints the actions' outputs on standard output.
If I want to pipe the outputs to a tool, like `jq`, I need to explicitly set the output format to json with `--output-format json`. But that format should be the default when I am piping the output. This is already what we do for logging: log format defaults to json when output is not a tty.
|
https://github.com/dagger/dagger/issues/2474
|
https://github.com/dagger/dagger/pull/2487
|
9e4b0551936d5c9689065ce5e22eb18cc7088f19
|
9ee0a85e6ed190a3868e0c3eba82a373ebb62823
| 2022-05-18T17:54:08Z |
go
| 2022-05-20T01:23:40Z |
cmd/dagger/cmd/do.go
|
if p == nil {
return nil
}
if action == nil {
return fmt.Errorf("action %s not found", target.String())
}
if len(action.Name) < 1 {
return nil
}
fmt.Printf("\nAvailable Actions:\n")
tw := tabwriter.NewWriter(w, 0, 0, 1, ' ', tabwriter.StripEscape)
defer tw.Flush()
for _, a := range action.Children {
if !a.Hidden {
lineParts := []string{"", a.Name, a.Documentation}
fmt.Fprintln(tw, strings.Join(lineParts, "\t"))
}
}
return nil
}
func init() {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,474 |
Output format should be json when stdout is not tty
|
`dagger do` prints the actions' outputs on standard output.
If I want to pipe the outputs to a tool, like `jq`, I need to explicitly set the output format to json with `--output-format json`. But that format should be the default when I am piping the output. This is already what we do for logging: log format defaults to json when output is not a tty.
|
https://github.com/dagger/dagger/issues/2474
|
https://github.com/dagger/dagger/pull/2487
|
9e4b0551936d5c9689065ce5e22eb18cc7088f19
|
9ee0a85e6ed190a3868e0c3eba82a373ebb62823
| 2022-05-18T17:54:08Z |
go
| 2022-05-20T01:23:40Z |
cmd/dagger/cmd/do.go
|
doCmd.Flags().StringArrayP("with", "w", []string{}, "")
doCmd.Flags().StringP("plan", "p", ".", "Path to plan (defaults to current directory)")
doCmd.Flags().Bool("dry-run", false, "Dry run mode")
doCmd.Flags().Bool("no-cache", false, "Disable caching")
doCmd.Flags().String("platform", "", "Set target build platform (requires experimental)")
doCmd.Flags().String("output", "", "File path to write the action's output values. Prints to stdout if empty")
doCmd.Flags().String("output-format", "plain", "Format for output values (plain, json, yaml)")
doCmd.Flags().StringArray("cache-to", []string{},
"Cache export destinations (eg. user/app:cache, type=local,dest=path/to/dir)")
doCmd.Flags().StringArray("cache-from", []string{},
"External cache sources (eg. user/app:cache, type=local,src=path/to/dir)")
doCmd.SetUsageTemplate(`{{if .HasAvailableSubCommands}}
{{.CommandPath}} [command]{{end}}{{if gt (len .Aliases) 0}}
Aliases:
{{.NameAndAliases}}{{end}}{{if .HasExample}}
Examples:
{{.Example}}{{end}}{{if .HasAvailableSubCommands}}
Available Commands:{{range .Commands}}{{if (or .IsAvailableCommand (eq .Name "help"))}}
{{rpad .Name .NamePadding }} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableLocalFlags}}
Flags:
{{.LocalFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasAvailableInheritedFlags}}
Global Flags:
{{.InheritedFlags.FlagUsages | trimTrailingWhitespaces}}{{end}}{{if .HasHelpSubCommands}}
Additional help topics:{{range .Commands}}{{if .IsAdditionalHelpTopicCommand}}
{{rpad .CommandPath .CommandPathPadding}} {{.Short}}{{end}}{{end}}{{end}}{{if .HasAvailableSubCommands}}
Use "{{.CommandPath}} [command] --help" for more information about a command.{{end}}
`)
}
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,079 |
🐞 "FTL" is confusing in error messages
|
### What is the issue?
Error messages start with the word "FTL", for example:
```
5:15AM FTL failed to execute plan: task failed: actions.lint.markdown._exec: process "/home/nonroot/entrypoint.sh markdownlint ./docs README.md" did not complete successfully: exit code: 1
```
Several people have asked me "what does FTL mean"? The answer is "fatal error". But clearly that is not at all obvious.
### Log output
-
### Steps to reproduce
Run `dagger do` of an action that fails. Look at output.
### Dagger version
dagger devel (fb3eafb6) linux/amd64
### OS version
Linux ip-172-31-39-148 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 Linux
|
https://github.com/dagger/dagger/issues/2079
|
https://github.com/dagger/dagger/pull/2595
|
19bfa7a0ad719934b46433358d3e5db68f8ca68d
|
725b5c2f38f123a10d00411c17e4f2ecd02610c6
| 2022-04-08T05:18:43Z |
go
| 2022-06-10T00:01:11Z |
cmd/dagger/logger/plain.go
|
package logger
import (
"bytes"
"encoding/json"
"fmt"
"hash/adler32"
"io"
"sort"
"strings"
"time"
"github.com/mitchellh/colorstring"
"github.com/rs/zerolog"
)
var colorize = colorstring.Colorize{
Colors: colorstring.DefaultColors,
Reset: true,
}
type PlainOutput struct {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,079 |
🐞 "FTL" is confusing in error messages
|
### What is the issue?
Error messages start with the word "FTL", for example:
```
5:15AM FTL failed to execute plan: task failed: actions.lint.markdown._exec: process "/home/nonroot/entrypoint.sh markdownlint ./docs README.md" did not complete successfully: exit code: 1
```
Several people have asked me "what does FTL mean"? The answer is "fatal error". But clearly that is not at all obvious.
### Log output
-
### Steps to reproduce
Run `dagger do` of an action that fails. Look at output.
### Dagger version
dagger devel (fb3eafb6) linux/amd64
### OS version
Linux ip-172-31-39-148 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 Linux
|
https://github.com/dagger/dagger/issues/2079
|
https://github.com/dagger/dagger/pull/2595
|
19bfa7a0ad719934b46433358d3e5db68f8ca68d
|
725b5c2f38f123a10d00411c17e4f2ecd02610c6
| 2022-04-08T05:18:43Z |
go
| 2022-06-10T00:01:11Z |
cmd/dagger/logger/plain.go
|
Out io.Writer
}
const systemGroup = "system"
func (c *PlainOutput) Write(p []byte) (int, error) {
event := map[string]interface{}{}
d := json.NewDecoder(bytes.NewReader(p))
if err := d.Decode(&event); err != nil {
return 0, fmt.Errorf("cannot decode event: %s", err)
}
source := parseSource(event)
fmt.Fprintln(c.Out, colorize.Color(fmt.Sprintf("%s %s %s%s%s",
formatTimestamp(event),
formatLevel(event),
formatSource(source),
formatMessage(event),
formatFields(event),
)))
return len(p), nil
}
func formatLevel(event map[string]interface{}) string {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,079 |
🐞 "FTL" is confusing in error messages
|
### What is the issue?
Error messages start with the word "FTL", for example:
```
5:15AM FTL failed to execute plan: task failed: actions.lint.markdown._exec: process "/home/nonroot/entrypoint.sh markdownlint ./docs README.md" did not complete successfully: exit code: 1
```
Several people have asked me "what does FTL mean"? The answer is "fatal error". But clearly that is not at all obvious.
### Log output
-
### Steps to reproduce
Run `dagger do` of an action that fails. Look at output.
### Dagger version
dagger devel (fb3eafb6) linux/amd64
### OS version
Linux ip-172-31-39-148 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 Linux
|
https://github.com/dagger/dagger/issues/2079
|
https://github.com/dagger/dagger/pull/2595
|
19bfa7a0ad719934b46433358d3e5db68f8ca68d
|
725b5c2f38f123a10d00411c17e4f2ecd02610c6
| 2022-04-08T05:18:43Z |
go
| 2022-06-10T00:01:11Z |
cmd/dagger/logger/plain.go
|
level := zerolog.DebugLevel
if l, ok := event[zerolog.LevelFieldName].(string); ok {
level, _ = zerolog.ParseLevel(l)
}
switch level {
case zerolog.TraceLevel:
return "[magenta]TRC[reset]"
case zerolog.DebugLevel:
return "[yellow]DBG[reset]"
case zerolog.InfoLevel:
return "[green]INF[reset]"
case zerolog.WarnLevel:
return "[red]WRN[reset]"
case zerolog.ErrorLevel:
return "[red]ERR[reset]"
case zerolog.FatalLevel:
return "[red]FTL[reset]"
case zerolog.PanicLevel:
return "[red]PNC[reset]"
default:
return "[bold]???[reset]"
}
}
func formatTimestamp(event map[string]interface{}) string {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,079 |
🐞 "FTL" is confusing in error messages
|
### What is the issue?
Error messages start with the word "FTL", for example:
```
5:15AM FTL failed to execute plan: task failed: actions.lint.markdown._exec: process "/home/nonroot/entrypoint.sh markdownlint ./docs README.md" did not complete successfully: exit code: 1
```
Several people have asked me "what does FTL mean"? The answer is "fatal error". But clearly that is not at all obvious.
### Log output
-
### Steps to reproduce
Run `dagger do` of an action that fails. Look at output.
### Dagger version
dagger devel (fb3eafb6) linux/amd64
### OS version
Linux ip-172-31-39-148 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 Linux
|
https://github.com/dagger/dagger/issues/2079
|
https://github.com/dagger/dagger/pull/2595
|
19bfa7a0ad719934b46433358d3e5db68f8ca68d
|
725b5c2f38f123a10d00411c17e4f2ecd02610c6
| 2022-04-08T05:18:43Z |
go
| 2022-06-10T00:01:11Z |
cmd/dagger/logger/plain.go
|
ts, ok := event[zerolog.TimestampFieldName].(string)
if !ok {
return "???"
}
t, err := time.Parse(zerolog.TimeFieldFormat, ts)
if err != nil {
panic(err)
}
return fmt.Sprintf("[dark_gray]%s[reset]", t.Format(time.Kitchen))
}
func formatMessage(event map[string]interface{}) string {
message, ok := event[zerolog.MessageFieldName].(string)
if !ok {
return ""
}
message = strings.TrimSpace(message)
if err, ok := event[zerolog.ErrorFieldName].(string); ok && err != "" {
message = message + ": " + err
}
level := zerolog.DebugLevel
if l, ok := event[zerolog.LevelFieldName].(string); ok {
level, _ = zerolog.ParseLevel(l)
}
switch level {
case zerolog.TraceLevel:
return fmt.Sprintf("[dim]%s[reset]", message)
case zerolog.DebugLevel:
return fmt.Sprintf("[dim]%s[reset]", message)
case zerolog.InfoLevel:
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,079 |
🐞 "FTL" is confusing in error messages
|
### What is the issue?
Error messages start with the word "FTL", for example:
```
5:15AM FTL failed to execute plan: task failed: actions.lint.markdown._exec: process "/home/nonroot/entrypoint.sh markdownlint ./docs README.md" did not complete successfully: exit code: 1
```
Several people have asked me "what does FTL mean"? The answer is "fatal error". But clearly that is not at all obvious.
### Log output
-
### Steps to reproduce
Run `dagger do` of an action that fails. Look at output.
### Dagger version
dagger devel (fb3eafb6) linux/amd64
### OS version
Linux ip-172-31-39-148 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 Linux
|
https://github.com/dagger/dagger/issues/2079
|
https://github.com/dagger/dagger/pull/2595
|
19bfa7a0ad719934b46433358d3e5db68f8ca68d
|
725b5c2f38f123a10d00411c17e4f2ecd02610c6
| 2022-04-08T05:18:43Z |
go
| 2022-06-10T00:01:11Z |
cmd/dagger/logger/plain.go
|
return message
case zerolog.WarnLevel:
return fmt.Sprintf("[yellow]%s[reset]", message)
case zerolog.ErrorLevel:
return fmt.Sprintf("[red]%s[reset]", message)
case zerolog.FatalLevel:
return fmt.Sprintf("[red]%s[reset]", message)
case zerolog.PanicLevel:
return fmt.Sprintf("[red]%s[reset]", message)
default:
return message
}
}
func parseSource(event map[string]interface{}) string {
source := systemGroup
if task, ok := event["task"].(string); ok && task != "" {
source = task
}
return source
}
func formatSource(source string) string {
return fmt.Sprintf("[%s]%s | [reset]",
hashColor(source),
source,
)
}
func formatFields(entry map[string]interface{}) string {
fieldSkipList := map[string]struct{}{
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,079 |
🐞 "FTL" is confusing in error messages
|
### What is the issue?
Error messages start with the word "FTL", for example:
```
5:15AM FTL failed to execute plan: task failed: actions.lint.markdown._exec: process "/home/nonroot/entrypoint.sh markdownlint ./docs README.md" did not complete successfully: exit code: 1
```
Several people have asked me "what does FTL mean"? The answer is "fatal error". But clearly that is not at all obvious.
### Log output
-
### Steps to reproduce
Run `dagger do` of an action that fails. Look at output.
### Dagger version
dagger devel (fb3eafb6) linux/amd64
### OS version
Linux ip-172-31-39-148 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 Linux
|
https://github.com/dagger/dagger/issues/2079
|
https://github.com/dagger/dagger/pull/2595
|
19bfa7a0ad719934b46433358d3e5db68f8ca68d
|
725b5c2f38f123a10d00411c17e4f2ecd02610c6
| 2022-04-08T05:18:43Z |
go
| 2022-06-10T00:01:11Z |
cmd/dagger/logger/plain.go
|
zerolog.MessageFieldName: {},
zerolog.LevelFieldName: {},
zerolog.TimestampFieldName: {},
zerolog.ErrorFieldName: {},
zerolog.CallerFieldName: {},
"environment": {},
"task": {},
"state": {},
}
fields := []string{}
for key, value := range entry {
if _, ok := fieldSkipList[key]; ok {
continue
}
switch v := value.(type) {
case string:
fields = append(fields, fmt.Sprintf("%s=%s", key, v))
case int:
fields = append(fields, fmt.Sprintf("%s=%v", key, v))
case float64:
dur := time.Duration(v) * time.Millisecond
s := dur.Round(100 * time.Millisecond).String()
fields = append(fields, fmt.Sprintf("%s=%s", key, s))
case nil:
fields = append(fields, fmt.Sprintf("%s=null", key))
default:
o, err := json.MarshalIndent(v, "", " ")
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,079 |
🐞 "FTL" is confusing in error messages
|
### What is the issue?
Error messages start with the word "FTL", for example:
```
5:15AM FTL failed to execute plan: task failed: actions.lint.markdown._exec: process "/home/nonroot/entrypoint.sh markdownlint ./docs README.md" did not complete successfully: exit code: 1
```
Several people have asked me "what does FTL mean"? The answer is "fatal error". But clearly that is not at all obvious.
### Log output
-
### Steps to reproduce
Run `dagger do` of an action that fails. Look at output.
### Dagger version
dagger devel (fb3eafb6) linux/amd64
### OS version
Linux ip-172-31-39-148 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 Linux
|
https://github.com/dagger/dagger/issues/2079
|
https://github.com/dagger/dagger/pull/2595
|
19bfa7a0ad719934b46433358d3e5db68f8ca68d
|
725b5c2f38f123a10d00411c17e4f2ecd02610c6
| 2022-04-08T05:18:43Z |
go
| 2022-06-10T00:01:11Z |
cmd/dagger/logger/plain.go
|
if err != nil {
panic(err)
}
fields = append(fields, fmt.Sprintf("%s=%s", key, o))
}
}
if len(fields) == 0 {
return ""
}
sort.SliceStable(fields, func(i, j int) bool {
return fields[i] < fields[j]
})
return fmt.Sprintf(" [bold]%s[reset]", strings.Join(fields, " "))
}
func hashColor(text string) string {
colors := []string{
"green",
"light_green",
"light_blue",
"blue",
"magenta",
"light_magenta",
"light_yellow",
"cyan",
"light_cyan",
}
h := adler32.Checksum([]byte(text))
return colors[int(h)%len(colors)]
}
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,543 |
Incomplete documentation for Publishing packages on Repository
|
### What is the issue?
# Context
as documented in [push-package-on-repository](https://docs.dagger.io/1239/making-reusable-package#push-package-on-repository)
> [...] you will directly be able to retrieve the personal package using the dagger project update url@tag command.
Consumers of the package can retrieve the package by the _tag_ however the documentation does not specify any specific format of the tag when pushing the library to the repository.
# Problem
as per the [implementation](https://sourcegraph.com/github.com/dagger/dagger@dde2fe8a369335a9570c335f2088982d05f26fda/-/blob/mod/repo.go?L121&popover=pinned), `dagger` will **actually** enforce the tag in a format that is compatible to the [upstream cue-lang package versioning](https://github.com/cue-lang/cue/issues/851), to be clear this is `v<tag>`. Without this knowledge - it is pretty difficult to find out the reason without enabling the `debug` logs.
**without** `debug` logs
```
dagger project update -u
8:54AM INF system | updating all installed packages...
8:54AM ERR system | error installing/updating packages: repo doesn't have any tags matching the required version
```
**with** `debug` logs
```
dagger project update -u --log-level debug
10:51AM INF system | updating all installed packages...
10:51AM DBG system | updating module name=github.com/xxxx/[email protected]
10:51AM DBG system | checkout repo commit=4c9d7dbc5aa14389f3c5df2e551fd423f48d5b88 repository=github.com/xxxx/mylib version=0.0.1
10:51AM DBG system | tag version ignored, wrong format repository=github.com/xxxx/mylib tag=0.0.1 versionConstraint=
```
# Solution
## Option 1 - Be Explicit (preferred)
1 . Update the above mentioned documentation and include and explain the tag format and reason for enforcing this rule.
2. Add *warn* message that the tag mentioned during
```
dagger project update github.com/xxxx/mylib@tag
```
does not comply with the tag format.
## Option 2 - Remove the enforcement of the tag format
The idea is not remove the tag format, until the package management of cuelang is finalized.
|
https://github.com/dagger/dagger/issues/2543
|
https://github.com/dagger/dagger/pull/2670
|
20fea021172615ed53d21d6f7e8b2c64479fafe5
|
170f47682cd1e5098fcd63c28852bca51e211920
| 2022-06-01T08:32:24Z |
go
| 2022-06-18T21:55:47Z |
mod/repo.go
|
package mod
import (
"context"
"fmt"
"os"
"sort"
"strings"
"github.com/go-git/go-git/v5/plumbing/transport/ssh"
"github.com/rs/zerolog/log"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing"
"github.com/hashicorp/go-version"
)
type repo struct {
contents *git.Repository
require *Require
}
func clone(ctx context.Context, require *Require, dir string, privateKeyFile, privateKeyPassword string) (*repo, error) {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,543 |
Incomplete documentation for Publishing packages on Repository
|
### What is the issue?
# Context
as documented in [push-package-on-repository](https://docs.dagger.io/1239/making-reusable-package#push-package-on-repository)
> [...] you will directly be able to retrieve the personal package using the dagger project update url@tag command.
Consumers of the package can retrieve the package by the _tag_ however the documentation does not specify any specific format of the tag when pushing the library to the repository.
# Problem
as per the [implementation](https://sourcegraph.com/github.com/dagger/dagger@dde2fe8a369335a9570c335f2088982d05f26fda/-/blob/mod/repo.go?L121&popover=pinned), `dagger` will **actually** enforce the tag in a format that is compatible to the [upstream cue-lang package versioning](https://github.com/cue-lang/cue/issues/851), to be clear this is `v<tag>`. Without this knowledge - it is pretty difficult to find out the reason without enabling the `debug` logs.
**without** `debug` logs
```
dagger project update -u
8:54AM INF system | updating all installed packages...
8:54AM ERR system | error installing/updating packages: repo doesn't have any tags matching the required version
```
**with** `debug` logs
```
dagger project update -u --log-level debug
10:51AM INF system | updating all installed packages...
10:51AM DBG system | updating module name=github.com/xxxx/[email protected]
10:51AM DBG system | checkout repo commit=4c9d7dbc5aa14389f3c5df2e551fd423f48d5b88 repository=github.com/xxxx/mylib version=0.0.1
10:51AM DBG system | tag version ignored, wrong format repository=github.com/xxxx/mylib tag=0.0.1 versionConstraint=
```
# Solution
## Option 1 - Be Explicit (preferred)
1 . Update the above mentioned documentation and include and explain the tag format and reason for enforcing this rule.
2. Add *warn* message that the tag mentioned during
```
dagger project update github.com/xxxx/mylib@tag
```
does not comply with the tag format.
## Option 2 - Remove the enforcement of the tag format
The idea is not remove the tag format, until the package management of cuelang is finalized.
|
https://github.com/dagger/dagger/issues/2543
|
https://github.com/dagger/dagger/pull/2670
|
20fea021172615ed53d21d6f7e8b2c64479fafe5
|
170f47682cd1e5098fcd63c28852bca51e211920
| 2022-06-01T08:32:24Z |
go
| 2022-06-18T21:55:47Z |
mod/repo.go
|
if err := os.RemoveAll(dir); err != nil {
return nil, fmt.Errorf("error cleaning up tmp directory")
}
if err := os.MkdirAll(dir, 0755); err != nil {
return nil, fmt.Errorf("error creating tmp dir for cloning package")
}
o := git.CloneOptions{
URL: fmt.Sprintf("https://%s", require.cloneRepo),
}
if privateKeyFile != "" {
publicKeys, err := ssh.NewPublicKeysFromFile("git", privateKeyFile, privateKeyPassword)
if err != nil {
return nil, err
}
o.Auth = publicKeys
o.URL = fmt.Sprintf("git@%s", strings.Replace(require.cloneRepo, "/", ":", 1))
}
r, err := git.PlainClone(dir, false, &o)
if err != nil {
return nil, err
}
rr := &repo{
contents: r,
require: require,
}
if require.version == "" {
latestTag, err := rr.latestTag(ctx, require.versionConstraint)
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,543 |
Incomplete documentation for Publishing packages on Repository
|
### What is the issue?
# Context
as documented in [push-package-on-repository](https://docs.dagger.io/1239/making-reusable-package#push-package-on-repository)
> [...] you will directly be able to retrieve the personal package using the dagger project update url@tag command.
Consumers of the package can retrieve the package by the _tag_ however the documentation does not specify any specific format of the tag when pushing the library to the repository.
# Problem
as per the [implementation](https://sourcegraph.com/github.com/dagger/dagger@dde2fe8a369335a9570c335f2088982d05f26fda/-/blob/mod/repo.go?L121&popover=pinned), `dagger` will **actually** enforce the tag in a format that is compatible to the [upstream cue-lang package versioning](https://github.com/cue-lang/cue/issues/851), to be clear this is `v<tag>`. Without this knowledge - it is pretty difficult to find out the reason without enabling the `debug` logs.
**without** `debug` logs
```
dagger project update -u
8:54AM INF system | updating all installed packages...
8:54AM ERR system | error installing/updating packages: repo doesn't have any tags matching the required version
```
**with** `debug` logs
```
dagger project update -u --log-level debug
10:51AM INF system | updating all installed packages...
10:51AM DBG system | updating module name=github.com/xxxx/[email protected]
10:51AM DBG system | checkout repo commit=4c9d7dbc5aa14389f3c5df2e551fd423f48d5b88 repository=github.com/xxxx/mylib version=0.0.1
10:51AM DBG system | tag version ignored, wrong format repository=github.com/xxxx/mylib tag=0.0.1 versionConstraint=
```
# Solution
## Option 1 - Be Explicit (preferred)
1 . Update the above mentioned documentation and include and explain the tag format and reason for enforcing this rule.
2. Add *warn* message that the tag mentioned during
```
dagger project update github.com/xxxx/mylib@tag
```
does not comply with the tag format.
## Option 2 - Remove the enforcement of the tag format
The idea is not remove the tag format, until the package management of cuelang is finalized.
|
https://github.com/dagger/dagger/issues/2543
|
https://github.com/dagger/dagger/pull/2670
|
20fea021172615ed53d21d6f7e8b2c64479fafe5
|
170f47682cd1e5098fcd63c28852bca51e211920
| 2022-06-01T08:32:24Z |
go
| 2022-06-18T21:55:47Z |
mod/repo.go
|
if err != nil {
return nil, err
}
require.version = latestTag
}
if err := rr.checkout(ctx, require.version); err != nil {
return nil, err
}
return rr, nil
}
func (r *repo) checkout(ctx context.Context, version string) error {
lg := log.Ctx(ctx)
h, err := r.contents.ResolveRevision(plumbing.Revision(version))
if err != nil {
return err
}
lg.Debug().Str("repository", r.require.repo).Str("version", version).Str("commit", h.String()).Msg("checkout repo")
w, err := r.contents.Worktree()
if err != nil {
return err
}
err = w.Checkout(&git.CheckoutOptions{
Hash: *h,
Force: true,
})
if err != nil {
return err
}
return nil
}
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,543 |
Incomplete documentation for Publishing packages on Repository
|
### What is the issue?
# Context
as documented in [push-package-on-repository](https://docs.dagger.io/1239/making-reusable-package#push-package-on-repository)
> [...] you will directly be able to retrieve the personal package using the dagger project update url@tag command.
Consumers of the package can retrieve the package by the _tag_ however the documentation does not specify any specific format of the tag when pushing the library to the repository.
# Problem
as per the [implementation](https://sourcegraph.com/github.com/dagger/dagger@dde2fe8a369335a9570c335f2088982d05f26fda/-/blob/mod/repo.go?L121&popover=pinned), `dagger` will **actually** enforce the tag in a format that is compatible to the [upstream cue-lang package versioning](https://github.com/cue-lang/cue/issues/851), to be clear this is `v<tag>`. Without this knowledge - it is pretty difficult to find out the reason without enabling the `debug` logs.
**without** `debug` logs
```
dagger project update -u
8:54AM INF system | updating all installed packages...
8:54AM ERR system | error installing/updating packages: repo doesn't have any tags matching the required version
```
**with** `debug` logs
```
dagger project update -u --log-level debug
10:51AM INF system | updating all installed packages...
10:51AM DBG system | updating module name=github.com/xxxx/[email protected]
10:51AM DBG system | checkout repo commit=4c9d7dbc5aa14389f3c5df2e551fd423f48d5b88 repository=github.com/xxxx/mylib version=0.0.1
10:51AM DBG system | tag version ignored, wrong format repository=github.com/xxxx/mylib tag=0.0.1 versionConstraint=
```
# Solution
## Option 1 - Be Explicit (preferred)
1 . Update the above mentioned documentation and include and explain the tag format and reason for enforcing this rule.
2. Add *warn* message that the tag mentioned during
```
dagger project update github.com/xxxx/mylib@tag
```
does not comply with the tag format.
## Option 2 - Remove the enforcement of the tag format
The idea is not remove the tag format, until the package management of cuelang is finalized.
|
https://github.com/dagger/dagger/issues/2543
|
https://github.com/dagger/dagger/pull/2670
|
20fea021172615ed53d21d6f7e8b2c64479fafe5
|
170f47682cd1e5098fcd63c28852bca51e211920
| 2022-06-01T08:32:24Z |
go
| 2022-06-18T21:55:47Z |
mod/repo.go
|
func (r *repo) listTagVersions(ctx context.Context, versionConstraint string) ([]string, error) {
lg := log.Ctx(ctx).With().
Str("repository", r.require.repo).
Str("versionConstraint", versionConstraint).
Logger()
if versionConstraint == "" {
versionConstraint = ">= 0"
}
constraint, err := version.NewConstraint(versionConstraint)
if err != nil {
return nil, err
}
iter, err := r.contents.Tags()
if err != nil {
return nil, err
}
var tags []string
err = iter.ForEach(func(ref *plumbing.Reference) error {
tagV := ref.Name().Short()
if !strings.HasPrefix(tagV, "v") {
lg.Debug().Str("tag", tagV).Msg("tag version ignored, wrong format")
return nil
}
v, err := version.NewVersion(tagV)
if err != nil {
lg.Debug().Str("tag", tagV).Err(err).Msg("tag version ignored, parsing error")
return nil
}
if constraint.Check(v) {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 2,543 |
Incomplete documentation for Publishing packages on Repository
|
### What is the issue?
# Context
as documented in [push-package-on-repository](https://docs.dagger.io/1239/making-reusable-package#push-package-on-repository)
> [...] you will directly be able to retrieve the personal package using the dagger project update url@tag command.
Consumers of the package can retrieve the package by the _tag_ however the documentation does not specify any specific format of the tag when pushing the library to the repository.
# Problem
as per the [implementation](https://sourcegraph.com/github.com/dagger/dagger@dde2fe8a369335a9570c335f2088982d05f26fda/-/blob/mod/repo.go?L121&popover=pinned), `dagger` will **actually** enforce the tag in a format that is compatible to the [upstream cue-lang package versioning](https://github.com/cue-lang/cue/issues/851), to be clear this is `v<tag>`. Without this knowledge - it is pretty difficult to find out the reason without enabling the `debug` logs.
**without** `debug` logs
```
dagger project update -u
8:54AM INF system | updating all installed packages...
8:54AM ERR system | error installing/updating packages: repo doesn't have any tags matching the required version
```
**with** `debug` logs
```
dagger project update -u --log-level debug
10:51AM INF system | updating all installed packages...
10:51AM DBG system | updating module name=github.com/xxxx/[email protected]
10:51AM DBG system | checkout repo commit=4c9d7dbc5aa14389f3c5df2e551fd423f48d5b88 repository=github.com/xxxx/mylib version=0.0.1
10:51AM DBG system | tag version ignored, wrong format repository=github.com/xxxx/mylib tag=0.0.1 versionConstraint=
```
# Solution
## Option 1 - Be Explicit (preferred)
1 . Update the above mentioned documentation and include and explain the tag format and reason for enforcing this rule.
2. Add *warn* message that the tag mentioned during
```
dagger project update github.com/xxxx/mylib@tag
```
does not comply with the tag format.
## Option 2 - Remove the enforcement of the tag format
The idea is not remove the tag format, until the package management of cuelang is finalized.
|
https://github.com/dagger/dagger/issues/2543
|
https://github.com/dagger/dagger/pull/2670
|
20fea021172615ed53d21d6f7e8b2c64479fafe5
|
170f47682cd1e5098fcd63c28852bca51e211920
| 2022-06-01T08:32:24Z |
go
| 2022-06-18T21:55:47Z |
mod/repo.go
|
tags = append(tags, ref.Name().Short())
lg.Debug().Str("tag", tagV).Msg("version added")
} else {
lg.Debug().Str("tag", tagV).Msg("tag version ignored, does not satisfy constraint")
}
return nil
})
if err != nil {
return nil, err
}
return tags, nil
}
func (r *repo) latestTag(ctx context.Context, versionConstraint string) (string, error) {
versionsRaw, err := r.listTagVersions(ctx, versionConstraint)
if err != nil {
return "", err
}
versions := make([]*version.Version, len(versionsRaw))
for i, raw := range versionsRaw {
v, _ := version.NewVersion(raw)
versions[i] = v
}
if len(versions) == 0 {
return "", fmt.Errorf("repo doesn't have any tags matching the required version")
}
sort.Sort(sort.Reverse(version.Collection(versions)))
version := versions[0].Original()
return version, nil
}
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 1,872 |
Bring back `dagger doc`
|
## Problem
Dagger 0.1 had a command called `dagger doc`, which was similar to `go doc`. Given the names of a CUE package and definition, it would print information about their API.
Unfortunately, this feature was not compatible with Dagger 0.2, because it relied on concepts such as `@dagger(input)` and `@dagger(output)` which no longer exist. This is also why we currently don't have an API reference in our docs: the generator has not been ported to 0.2.
As a result, there is no easy way to look up available packages and their APIs while developing a Dagger 0.2 plan.
## Solution
Bring back `dagger doc` in a simpler form. Instead of scanning the CUE code and generating documentation, just print the CUE code as is. The output can be refined later - but at least developers get the equivalent of looking up the source file on github, which is what they need to do anyway. It's a strictly better developer experience, achievable in the short term.
|
https://github.com/dagger/dagger/issues/1872
|
https://github.com/dagger/dagger/pull/2693
|
a7d453ea93610431d42ff9c8735e4befbbfdaea2
|
7f87e7bb34547fe814f60cbc09440fef0b4ec103
| 2022-03-27T06:23:01Z |
go
| 2022-07-05T17:17:40Z |
cmd/dagger/cmd/doc.go
|
package cmd
import (
"context"
"encoding/json"
"fmt"
"io/fs"
"os"
"path"
"path/filepath"
"sort"
"strings"
"text/tabwriter"
"unicode/utf8"
"cuelang.org/go/cue"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"go.dagger.io/dagger/cmd/dagger/cmd/common"
"go.dagger.io/dagger/cmd/dagger/logger"
"go.dagger.io/dagger/compiler"
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 1,872 |
Bring back `dagger doc`
|
## Problem
Dagger 0.1 had a command called `dagger doc`, which was similar to `go doc`. Given the names of a CUE package and definition, it would print information about their API.
Unfortunately, this feature was not compatible with Dagger 0.2, because it relied on concepts such as `@dagger(input)` and `@dagger(output)` which no longer exist. This is also why we currently don't have an API reference in our docs: the generator has not been ported to 0.2.
As a result, there is no easy way to look up available packages and their APIs while developing a Dagger 0.2 plan.
## Solution
Bring back `dagger doc` in a simpler form. Instead of scanning the CUE code and generating documentation, just print the CUE code as is. The output can be refined later - but at least developers get the equivalent of looking up the source file on github, which is what they need to do anyway. It's a strictly better developer experience, achievable in the short term.
|
https://github.com/dagger/dagger/issues/1872
|
https://github.com/dagger/dagger/pull/2693
|
a7d453ea93610431d42ff9c8735e4befbbfdaea2
|
7f87e7bb34547fe814f60cbc09440fef0b4ec103
| 2022-03-27T06:23:01Z |
go
| 2022-07-05T17:17:40Z |
cmd/dagger/cmd/doc.go
|
"go.dagger.io/dagger/pkg"
"golang.org/x/term"
)
const (
textFormat = "txt"
markdownFormat = "md"
jsonFormat = "json"
textPadding = " "
)
type Value struct {
Name string
Type string
Description string
type Field struct {
Name string
Description string
Inputs []Value
Outputs []Value
type Package struct {
Name string
ShortName string
Description string
Fields []Field
func Parse(ctx context.Context, packageName string, val *compiler.Value) *Package {
lg := log.Ctx(ctx)
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 1,872 |
Bring back `dagger doc`
|
## Problem
Dagger 0.1 had a command called `dagger doc`, which was similar to `go doc`. Given the names of a CUE package and definition, it would print information about their API.
Unfortunately, this feature was not compatible with Dagger 0.2, because it relied on concepts such as `@dagger(input)` and `@dagger(output)` which no longer exist. This is also why we currently don't have an API reference in our docs: the generator has not been ported to 0.2.
As a result, there is no easy way to look up available packages and their APIs while developing a Dagger 0.2 plan.
## Solution
Bring back `dagger doc` in a simpler form. Instead of scanning the CUE code and generating documentation, just print the CUE code as is. The output can be refined later - but at least developers get the equivalent of looking up the source file on github, which is what they need to do anyway. It's a strictly better developer experience, achievable in the short term.
|
https://github.com/dagger/dagger/issues/1872
|
https://github.com/dagger/dagger/pull/2693
|
a7d453ea93610431d42ff9c8735e4befbbfdaea2
|
7f87e7bb34547fe814f60cbc09440fef0b4ec103
| 2022-03-27T06:23:01Z |
go
| 2022-07-05T17:17:40Z |
cmd/dagger/cmd/doc.go
|
//
//
fields, err := val.Fields(cue.Definitions(true))
lg.Fatal().Err(err).Msg("cannot get fields")
pkg := &Package{
pkg.Name = packageName
parts := strings.Split(packageName, "/")
pkg.ShortName = parts[len(parts)-1:][0]
pkg.Description = common.ValueDocFull(val)
for _, f := range fields {
field := Field{
if !f.Selector.IsDefinition() {
continue
name := f.Label()
v := f.Value
if v.Cue().IncompleteKind() != cue.StructKind {
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 1,872 |
Bring back `dagger doc`
|
## Problem
Dagger 0.1 had a command called `dagger doc`, which was similar to `go doc`. Given the names of a CUE package and definition, it would print information about their API.
Unfortunately, this feature was not compatible with Dagger 0.2, because it relied on concepts such as `@dagger(input)` and `@dagger(output)` which no longer exist. This is also why we currently don't have an API reference in our docs: the generator has not been ported to 0.2.
As a result, there is no easy way to look up available packages and their APIs while developing a Dagger 0.2 plan.
## Solution
Bring back `dagger doc` in a simpler form. Instead of scanning the CUE code and generating documentation, just print the CUE code as is. The output can be refined later - but at least developers get the equivalent of looking up the source file on github, which is what they need to do anyway. It's a strictly better developer experience, achievable in the short term.
|
https://github.com/dagger/dagger/issues/1872
|
https://github.com/dagger/dagger/pull/2693
|
a7d453ea93610431d42ff9c8735e4befbbfdaea2
|
7f87e7bb34547fe814f60cbc09440fef0b4ec103
| 2022-03-27T06:23:01Z |
go
| 2022-07-05T17:17:40Z |
cmd/dagger/cmd/doc.go
|
continue
field.Name = name
field.Description = common.ValueDocOneLine(v)
pkg.Fields = append(pkg.Fields, field)
return pkg
func (p *Package) Format(f string) string {
switch f {
case textFormat:
return p.Text()
case jsonFormat:
return p.JSON()
case markdownFormat:
return p.Markdown()
default:
panic(f)
func (p *Package) JSON() string {
data, err := json.MarshalIndent(p, "", " ")
panic(err)
return fmt.Sprintf("%s\n", data)
func (p *Package) Text() string {
w := &strings.Builder{
fmt.Fprintf(w, "Package %s\n", p.Name)
fmt.Fprintf(w, "\n%s\n", p.Description)
fmt.Fprintf(w, "\nimport %q\n", p.Name)
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 1,872 |
Bring back `dagger doc`
|
## Problem
Dagger 0.1 had a command called `dagger doc`, which was similar to `go doc`. Given the names of a CUE package and definition, it would print information about their API.
Unfortunately, this feature was not compatible with Dagger 0.2, because it relied on concepts such as `@dagger(input)` and `@dagger(output)` which no longer exist. This is also why we currently don't have an API reference in our docs: the generator has not been ported to 0.2.
As a result, there is no easy way to look up available packages and their APIs while developing a Dagger 0.2 plan.
## Solution
Bring back `dagger doc` in a simpler form. Instead of scanning the CUE code and generating documentation, just print the CUE code as is. The output can be refined later - but at least developers get the equivalent of looking up the source file on github, which is what they need to do anyway. It's a strictly better developer experience, achievable in the short term.
|
https://github.com/dagger/dagger/issues/1872
|
https://github.com/dagger/dagger/pull/2693
|
a7d453ea93610431d42ff9c8735e4befbbfdaea2
|
7f87e7bb34547fe814f60cbc09440fef0b4ec103
| 2022-03-27T06:23:01Z |
go
| 2022-07-05T17:17:40Z |
cmd/dagger/cmd/doc.go
|
printValuesText := func(values []Value) {
tw := tabwriter.NewWriter(w, 0, 4, len(textPadding), ' ', 0)
for _, i := range values {
fmt.Fprintf(tw, "\t\t%s\t%s\t%s\n",
i.Name, i.Type, terminalTrim(i.Description))
tw.Flush()
for _, field := range p.Fields {
fmt.Fprintf(w, "\n%s.%s\n\n%s%s\n", p.ShortName, field.Name, textPadding, field.Description)
if len(field.Inputs) == 0 {
fmt.Fprintf(w, "\n%sInputs: none\n", textPadding)
else {
fmt.Fprintf(w, "\n%sInputs:\n", textPadding)
printValuesText(field.Inputs)
if len(field.Outputs) == 0 {
fmt.Fprintf(w, "\n%sOutputs: none\n", textPadding)
else {
fmt.Fprintf(w, "\n%sOutputs:\n", textPadding)
printValuesText(field.Outputs)
return w.String()
func terminalTrim(msg string) string {
size, _, err := term.GetSize(1)
return msg
|
closed
|
dagger/dagger
|
https://github.com/dagger/dagger
| 1,872 |
Bring back `dagger doc`
|
## Problem
Dagger 0.1 had a command called `dagger doc`, which was similar to `go doc`. Given the names of a CUE package and definition, it would print information about their API.
Unfortunately, this feature was not compatible with Dagger 0.2, because it relied on concepts such as `@dagger(input)` and `@dagger(output)` which no longer exist. This is also why we currently don't have an API reference in our docs: the generator has not been ported to 0.2.
As a result, there is no easy way to look up available packages and their APIs while developing a Dagger 0.2 plan.
## Solution
Bring back `dagger doc` in a simpler form. Instead of scanning the CUE code and generating documentation, just print the CUE code as is. The output can be refined later - but at least developers get the equivalent of looking up the source file on github, which is what they need to do anyway. It's a strictly better developer experience, achievable in the short term.
|
https://github.com/dagger/dagger/issues/1872
|
https://github.com/dagger/dagger/pull/2693
|
a7d453ea93610431d42ff9c8735e4befbbfdaea2
|
7f87e7bb34547fe814f60cbc09440fef0b4ec103
| 2022-03-27T06:23:01Z |
go
| 2022-07-05T17:17:40Z |
cmd/dagger/cmd/doc.go
|
size /= 2
for utf8.RuneCountInString(msg) > size {
msg = msg[0:len(msg)-4] + "…"
return msg
func (p *Package) Markdown() string {
w := &strings.Builder{
fmt.Fprintf(w, "---\nsidebar_label: %s\n---\n\n",
filepath.Base(p.Name),
)
fmt.Fprintf(w, "# %s\n", mdEscape(p.Name))
if p.Description != "-" {
fmt.Fprintf(w, "\n%s\n", mdEscape(p.Description))
fmt.Fprintf(w, "\n```cue\nimport %q\n```\n", p.Name)
printValuesMarkdown := func(values []Value) {
tw := tabwriter.NewWriter(w, 0, 4, len(textPadding), ' ', 0)
fmt.Fprintf(tw, "| Name\t| Type\t| Description \t|\n")
fmt.Fprintf(tw, "| -------------\t|:-------------:\t|:-------------:\t|\n")
for _, i := range values {
fmt.Fprintf(tw, "|*%s*\t| `%s`\t|%s\t|\n",
i.Name,
mdEscape(i.Type),
mdEscape(i.Description),
)
tw.Flush()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.