From bbeff0eddbaea2ce1551b588094685b289c7a921 Mon Sep 17 00:00:00 2001 From: Sam Alba Date: Wed, 14 Apr 2021 16:21:45 -0700 Subject: [PATCH] cmd: plugged no-cache option to all relevant commands Signed-off-by: Sam Alba --- cmd/dagger/cmd/common/common.go | 4 ++-- cmd/dagger/cmd/compute.go | 3 ++- cmd/dagger/cmd/new.go | 2 +- cmd/dagger/cmd/query.go | 2 +- cmd/dagger/cmd/up.go | 4 ++-- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cmd/dagger/cmd/common/common.go b/cmd/dagger/cmd/common/common.go index 83e17d70..5028a2b1 100644 --- a/cmd/dagger/cmd/common/common.go +++ b/cmd/dagger/cmd/common/common.go @@ -60,10 +60,10 @@ func GetCurrentDeploymentState(ctx context.Context, store *dagger.Store) *dagger } // Re-compute a deployment (equivalent to `dagger up`). -func DeploymentUp(ctx context.Context, state *dagger.DeploymentState) *dagger.Deployment { +func DeploymentUp(ctx context.Context, state *dagger.DeploymentState, noCache bool) *dagger.Deployment { lg := log.Ctx(ctx) - c, err := dagger.NewClient(ctx, "") + c, err := dagger.NewClient(ctx, "", noCache) if err != nil { lg.Fatal().Err(err).Msg("unable to create client") } diff --git a/cmd/dagger/cmd/compute.go b/cmd/dagger/cmd/compute.go index 9f2d32e4..4596315f 100644 --- a/cmd/dagger/cmd/compute.go +++ b/cmd/dagger/cmd/compute.go @@ -149,7 +149,7 @@ var computeCmd = &cobra.Command{ } } - deployment := common.DeploymentUp(ctx, st) + deployment := common.DeploymentUp(ctx, st, viper.GetBool("no-cache")) v := compiler.NewValue() if err := v.FillPath(cue.MakePath(), deployment.Plan()); err != nil { @@ -173,6 +173,7 @@ func init() { computeCmd.Flags().StringSlice("input-git", []string{}, "TARGET=REMOTE#REF") computeCmd.Flags().String("input-json", "", "JSON") computeCmd.Flags().String("input-yaml", "", "YAML") + computeCmd.Flags().Bool("no-cache", false, "disable cache") if err := viper.BindPFlags(computeCmd.Flags()); err != nil { panic(err) diff --git a/cmd/dagger/cmd/new.go b/cmd/dagger/cmd/new.go index 90d68468..9c3e3966 100644 --- a/cmd/dagger/cmd/new.go +++ b/cmd/dagger/cmd/new.go @@ -63,7 +63,7 @@ var newCmd = &cobra.Command{ Msg("deployment created") if viper.GetBool("up") { - common.DeploymentUp(ctx, st) + common.DeploymentUp(ctx, st, false) } }, } diff --git a/cmd/dagger/cmd/query.go b/cmd/dagger/cmd/query.go index 5680371f..3a1ed73a 100644 --- a/cmd/dagger/cmd/query.go +++ b/cmd/dagger/cmd/query.go @@ -47,7 +47,7 @@ var queryCmd = &cobra.Command{ cuePath = cue.ParsePath(args[0]) } - c, err := dagger.NewClient(ctx, "") + c, err := dagger.NewClient(ctx, "", false) if err != nil { lg.Fatal().Err(err).Msg("unable to create client") } diff --git a/cmd/dagger/cmd/up.go b/cmd/dagger/cmd/up.go index 7d6175e8..7e5a23e9 100644 --- a/cmd/dagger/cmd/up.go +++ b/cmd/dagger/cmd/up.go @@ -31,7 +31,7 @@ var upCmd = &cobra.Command{ state := common.GetCurrentDeploymentState(ctx, store) // TODO: Implement options: --no-cache - result := common.DeploymentUp(ctx, state) + result := common.DeploymentUp(ctx, state, viper.GetBool("no-cache")) state.Computed = result.Computed().JSON().String() if err := store.UpdateDeployment(ctx, state, nil); err != nil { lg.Fatal().Err(err).Msg("failed to update deployment") @@ -40,7 +40,7 @@ var upCmd = &cobra.Command{ } func init() { - newCmd.Flags().Bool("--no-cache", false, "Disable all run cache") + upCmd.Flags().Bool("no-cache", false, "Disable all run cache") if err := viper.BindPFlags(upCmd.Flags()); err != nil { panic(err)