From 817a73b7e0ac77691b4172c230f76e4849e1e506 Mon Sep 17 00:00:00 2001 From: Joel Longtine Date: Fri, 18 Feb 2022 14:48:35 -0700 Subject: [PATCH] Remove cmd output Signed-off-by: Joel Longtine --- cmd/dagger/cmd/output/dir.go | 33 ------------ cmd/dagger/cmd/output/list.go | 94 ----------------------------------- cmd/dagger/cmd/output/root.go | 14 ------ cmd/dagger/cmd/root.go | 2 - cmd/dagger/cmd/up.go | 3 +- 5 files changed, 1 insertion(+), 145 deletions(-) delete mode 100644 cmd/dagger/cmd/output/dir.go delete mode 100644 cmd/dagger/cmd/output/list.go delete mode 100644 cmd/dagger/cmd/output/root.go diff --git a/cmd/dagger/cmd/output/dir.go b/cmd/dagger/cmd/output/dir.go deleted file mode 100644 index b621dbc3..00000000 --- a/cmd/dagger/cmd/output/dir.go +++ /dev/null @@ -1,33 +0,0 @@ -package output - -import ( - "github.com/spf13/cobra" - "github.com/spf13/viper" -) - -var dirCmd = &cobra.Command{ - Use: "dir PATH", - Short: "Add a local directory as output artifact", - Args: cobra.ExactArgs(1), - PreRun: func(cmd *cobra.Command, args []string) { - // Fix Viper bug for duplicate flags: - // https://github.com/spf13/viper/issues/233 - 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()) - - panic("not implemented") - }, - // Remove hidden flag once command has been implemented - Hidden: true, -} - -func init() { - if err := viper.BindPFlags(dirCmd.Flags()); err != nil { - panic(err) - } -} diff --git a/cmd/dagger/cmd/output/list.go b/cmd/dagger/cmd/output/list.go deleted file mode 100644 index 36887693..00000000 --- a/cmd/dagger/cmd/output/list.go +++ /dev/null @@ -1,94 +0,0 @@ -package output - -import ( - "context" - "fmt" - "os" - "text/tabwriter" - - "go.dagger.io/dagger/cmd/dagger/cmd/common" - "go.dagger.io/dagger/cmd/dagger/logger" - "go.dagger.io/dagger/environment" - "go.dagger.io/dagger/solver" - - "github.com/rs/zerolog/log" - "github.com/spf13/cobra" - "github.com/spf13/viper" -) - -var listCmd = &cobra.Command{ - Use: "list [TARGET] [flags]", - Short: "List the outputs of an environment", - Args: cobra.MaximumNArgs(1), - PreRun: func(cmd *cobra.Command, args []string) { - // Fix Viper bug for duplicate flags: - // https://github.com/spf13/viper/issues/233 - 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()) - - project := common.CurrentProject(ctx) - st := common.CurrentEnvironmentState(ctx, project) - - lg = lg.With(). - Str("environment", st.Name). - Logger() - - doneCh := common.TrackProjectCommand(ctx, cmd, project, st) - - env, err := environment.New(st) - if err != nil { - lg.Fatal().Err(err).Msg("unable to create environment") - } - - cl := common.NewClient(ctx) - err = cl.Do(ctx, env.Context(), func(ctx context.Context, s solver.Solver) error { - return ListOutputs(ctx, env, true) - }) - - <-doneCh - - if err != nil { - lg.Fatal().Err(err).Msg("failed to scan outputs") - } - }, -} - -func ListOutputs(ctx context.Context, env *environment.Environment, isTTY bool) error { - lg := log.Ctx(ctx).With(). - Str("environment", env.Name()). - Logger() - - outputs, err := env.ScanOutputs(ctx) - if err != nil { - lg.Error().Err(err).Msg("failed to scan outputs") - return err - } - - if !isTTY { - for _, out := range outputs { - lg.Info().Str("name", out.Path().String()). - Str("value", fmt.Sprintf("%v", out.Cue())). - Msg("output") - } - return nil - } - - w := tabwriter.NewWriter(os.Stdout, 0, 4, 2, ' ', 0) - fmt.Fprintln(w, "Output\tValue\tDescription") - - for _, out := range outputs { - fmt.Fprintf(w, "%s\t%s\t%s\n", - out.Path(), - common.FormatValue(out), - common.ValueDocOneLine(out), - ) - } - - w.Flush() - return nil -} diff --git a/cmd/dagger/cmd/output/root.go b/cmd/dagger/cmd/output/root.go deleted file mode 100644 index c765c55d..00000000 --- a/cmd/dagger/cmd/output/root.go +++ /dev/null @@ -1,14 +0,0 @@ -package output - -import "github.com/spf13/cobra" - -// Cmd exposes the top-level command -var Cmd = &cobra.Command{ - Use: "output", - Short: "Manage an environment's outputs", -} - -func init() { - // Cmd.AddCommand(dirCmd) - Cmd.AddCommand(listCmd) -} diff --git a/cmd/dagger/cmd/root.go b/cmd/dagger/cmd/root.go index 7f3edecd..52f69fa3 100644 --- a/cmd/dagger/cmd/root.go +++ b/cmd/dagger/cmd/root.go @@ -8,7 +8,6 @@ import ( "github.com/spf13/cobra" "github.com/spf13/viper" "go.dagger.io/dagger/cmd/dagger/cmd/mod" - "go.dagger.io/dagger/cmd/dagger/cmd/output" "go.dagger.io/dagger/cmd/dagger/logger" "go.dagger.io/dagger/keychain" @@ -63,7 +62,6 @@ func init() { historyCmd, loginCmd, logoutCmd, - output.Cmd, versionCmd, docCmd, mod.Cmd, diff --git a/cmd/dagger/cmd/up.go b/cmd/dagger/cmd/up.go index aa9ca433..bf7c15c8 100644 --- a/cmd/dagger/cmd/up.go +++ b/cmd/dagger/cmd/up.go @@ -9,7 +9,6 @@ import ( "cuelang.org/go/cue" "go.dagger.io/dagger/client" "go.dagger.io/dagger/cmd/dagger/cmd/common" - "go.dagger.io/dagger/cmd/dagger/cmd/output" "go.dagger.io/dagger/cmd/dagger/logger" "go.dagger.io/dagger/compiler" "go.dagger.io/dagger/environment" @@ -108,7 +107,7 @@ var upCmd = &cobra.Command{ if tty != nil { tty.Stop() } - return output.ListOutputs(ctx, env, term.IsTerminal(int(os.Stdout.Fd()))) + return nil }) <-doneCh