cmd/up: show outputs at the end of the config execution

Signed-off-by: Sam Alba <sam.alba@gmail.com>
This commit is contained in:
Sam Alba 2021-05-31 16:14:57 +02:00
parent 44a919e7f8
commit d6b6142065
2 changed files with 56 additions and 47 deletions

View File

@ -12,7 +12,9 @@ import (
"go.dagger.io/dagger/cmd/dagger/logger"
"go.dagger.io/dagger/environment"
"go.dagger.io/dagger/solver"
"go.dagger.io/dagger/state"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
@ -35,7 +37,12 @@ var listCmd = &cobra.Command{
workspace := common.CurrentWorkspace(ctx)
st := common.CurrentEnvironmentState(ctx, workspace)
lg = lg.With().
ListOutputs(ctx, st, viper.GetBool("all"))
},
}
func ListOutputs(ctx context.Context, st *state.State, all bool) {
lg := log.Ctx(ctx).With().
Str("environment", st.Name).
Logger()
@ -61,7 +68,7 @@ var listCmd = &cobra.Command{
if err != nil {
return err
}
} else if !viper.GetBool("all") {
} else if !all {
continue
}
@ -82,7 +89,6 @@ var listCmd = &cobra.Command{
if err != nil {
lg.Fatal().Err(err).Msg("failed to query environment")
}
},
}
func init() {

View File

@ -7,6 +7,7 @@ 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"
@ -46,6 +47,8 @@ var upCmd = &cobra.Command{
if err := workspace.Save(ctx, st); err != nil {
lg.Fatal().Err(err).Msg("failed to update environment")
}
output.ListOutputs(ctx, st, false)
},
}