cmd: plugged no-cache option to all relevant commands
Signed-off-by: Sam Alba <sam.alba@gmail.com>
This commit is contained in:
parent
83f56897a7
commit
bbeff0eddb
@ -60,10 +60,10 @@ func GetCurrentDeploymentState(ctx context.Context, store *dagger.Store) *dagger
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Re-compute a deployment (equivalent to `dagger up`).
|
// 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)
|
lg := log.Ctx(ctx)
|
||||||
|
|
||||||
c, err := dagger.NewClient(ctx, "")
|
c, err := dagger.NewClient(ctx, "", noCache)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
lg.Fatal().Err(err).Msg("unable to create client")
|
lg.Fatal().Err(err).Msg("unable to create client")
|
||||||
}
|
}
|
||||||
|
@ -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()
|
v := compiler.NewValue()
|
||||||
if err := v.FillPath(cue.MakePath(), deployment.Plan()); err != nil {
|
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().StringSlice("input-git", []string{}, "TARGET=REMOTE#REF")
|
||||||
computeCmd.Flags().String("input-json", "", "JSON")
|
computeCmd.Flags().String("input-json", "", "JSON")
|
||||||
computeCmd.Flags().String("input-yaml", "", "YAML")
|
computeCmd.Flags().String("input-yaml", "", "YAML")
|
||||||
|
computeCmd.Flags().Bool("no-cache", false, "disable cache")
|
||||||
|
|
||||||
if err := viper.BindPFlags(computeCmd.Flags()); err != nil {
|
if err := viper.BindPFlags(computeCmd.Flags()); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@ -63,7 +63,7 @@ var newCmd = &cobra.Command{
|
|||||||
Msg("deployment created")
|
Msg("deployment created")
|
||||||
|
|
||||||
if viper.GetBool("up") {
|
if viper.GetBool("up") {
|
||||||
common.DeploymentUp(ctx, st)
|
common.DeploymentUp(ctx, st, false)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ var queryCmd = &cobra.Command{
|
|||||||
cuePath = cue.ParsePath(args[0])
|
cuePath = cue.ParsePath(args[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
c, err := dagger.NewClient(ctx, "")
|
c, err := dagger.NewClient(ctx, "", false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
lg.Fatal().Err(err).Msg("unable to create client")
|
lg.Fatal().Err(err).Msg("unable to create client")
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ var upCmd = &cobra.Command{
|
|||||||
state := common.GetCurrentDeploymentState(ctx, store)
|
state := common.GetCurrentDeploymentState(ctx, store)
|
||||||
|
|
||||||
// TODO: Implement options: --no-cache
|
// 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()
|
state.Computed = result.Computed().JSON().String()
|
||||||
if err := store.UpdateDeployment(ctx, state, nil); err != nil {
|
if err := store.UpdateDeployment(ctx, state, nil); err != nil {
|
||||||
lg.Fatal().Err(err).Msg("failed to update deployment")
|
lg.Fatal().Err(err).Msg("failed to update deployment")
|
||||||
@ -40,7 +40,7 @@ var upCmd = &cobra.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
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 {
|
if err := viper.BindPFlags(upCmd.Flags()); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
Reference in New Issue
Block a user