diff --git a/cmd/dagger/cmd/input/root.go b/cmd/dagger/cmd/input/root.go index ef1ae3cf..c681db4e 100644 --- a/cmd/dagger/cmd/input/root.go +++ b/cmd/dagger/cmd/input/root.go @@ -8,7 +8,10 @@ import ( "github.com/rs/zerolog/log" "github.com/spf13/cobra" "github.com/spf13/viper" + "go.dagger.io/dagger/client" "go.dagger.io/dagger/cmd/dagger/cmd/common" + "go.dagger.io/dagger/environment" + "go.dagger.io/dagger/solver" "go.dagger.io/dagger/state" ) @@ -32,13 +35,26 @@ func init() { ) } -func updateEnvironmentInput(ctx context.Context, target string, input state.Input) { +func updateEnvironmentInput(ctx context.Context, cl *client.Client, target string, input state.Input) { lg := log.Ctx(ctx) workspace := common.CurrentWorkspace(ctx) st := common.CurrentEnvironmentState(ctx, workspace) + st.SetInput(target, input) + _, err := cl.Do(ctx, st, func(ctx context.Context, env *environment.Environment, s solver.Solver) error { + _, err := env.ScanInputs(ctx, true) + if err != nil { + return err + } + return nil + }) + + if err != nil { + lg.Fatal().Err(err).Str("environment", st.Name).Msg("invalid input") + } + if err := workspace.Save(ctx, st); err != nil { lg.Fatal().Err(err).Str("environment", st.Name).Msg("cannot update environment") }