Skip to content

Commit 5f68279

Browse files
committed
refactor: reorder default flags
1 parent 43d9087 commit 5f68279

6 files changed

Lines changed: 56 additions & 33 deletions

File tree

cmd/build.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import (
88

99
// NewBuildCmd creates a new devspace build command
1010
func NewBuildCmd(f factory.Factory, globalFlags *flags.GlobalFlags) *cobra.Command {
11-
cmd := &RunPipelineCmd{GlobalFlags: globalFlags}
11+
cmd := &RunPipelineCmd{
12+
GlobalFlags: globalFlags,
13+
Pipeline: "build",
14+
ForceBuild: true,
15+
}
1216
buildCmd := &cobra.Command{
1317
Use: "build",
1418
Short: "Builds all defined images and pushes them",
@@ -23,6 +27,6 @@ Builds all defined images and pushes them
2327
},
2428
}
2529

26-
cmd.AddFlags(buildCmd, "build")
30+
cmd.AddFlags(buildCmd)
2731
return buildCmd
2832
}

cmd/deploy.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ import (
88

99
// NewDeployCmd creates a new deploy command
1010
func NewDeployCmd(f factory.Factory, globalFlags *flags.GlobalFlags) *cobra.Command {
11-
cmd := &RunPipelineCmd{GlobalFlags: globalFlags}
11+
cmd := &RunPipelineCmd{
12+
GlobalFlags: globalFlags,
13+
SkipPushLocalKubernetes: true,
14+
Pipeline: "deploy",
15+
}
16+
1217
deployCmd := &cobra.Command{
1318
Use: "deploy",
1419
Short: "Deploy the project",
@@ -28,6 +33,6 @@ devspace deploy --kube-context=deploy-context
2833
},
2934
}
3035

31-
cmd.AddFlags(deployCmd, "deploy")
36+
cmd.AddFlags(deployCmd)
3237
return deployCmd
3338
}

cmd/dev.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import (
88

99
// NewDevCmd creates a new devspace dev command
1010
func NewDevCmd(f factory.Factory, globalFlags *flags.GlobalFlags) *cobra.Command {
11-
cmd := &RunPipelineCmd{GlobalFlags: globalFlags}
11+
cmd := &RunPipelineCmd{
12+
GlobalFlags: globalFlags,
13+
SkipPushLocalKubernetes: true,
14+
Pipeline: "dev",
15+
}
1216
devCmd := &cobra.Command{
1317
Use: "dev",
1418
Short: "Starts the development mode",
@@ -24,6 +28,6 @@ Starts your project in development mode
2428
},
2529
}
2630

27-
cmd.AddFlags(devCmd, "dev")
31+
cmd.AddFlags(devCmd)
2832
return devCmd
2933
}

cmd/purge.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ import (
99

1010
// NewPurgeCmd creates a new purge command
1111
func NewPurgeCmd(f factory.Factory, globalFlags *flags.GlobalFlags) *cobra.Command {
12-
cmd := &RunPipelineCmd{GlobalFlags: globalFlags}
12+
cmd := &RunPipelineCmd{
13+
GlobalFlags: globalFlags,
14+
Pipeline: "purge",
15+
SkipPushLocalKubernetes: true,
16+
}
1317
purgeCmd := &cobra.Command{
1418
Use: "purge",
1519
Short: "Delete deployed resources",
@@ -27,6 +31,6 @@ devspace purge
2731
},
2832
}
2933

30-
cmd.AddFlags(purgeCmd, "purge")
34+
cmd.AddFlags(purgeCmd)
3135
return purgeCmd
3236
}

cmd/render.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ import (
1111
// NewRenderCmd creates a new devspace render command
1212
func NewRenderCmd(f factory.Factory, globalFlags *flags.GlobalFlags) *cobra.Command {
1313
cmd := &RunPipelineCmd{
14-
GlobalFlags: globalFlags,
15-
RenderWriter: os.Stdout,
14+
GlobalFlags: globalFlags,
15+
SkipPushLocalKubernetes: true,
16+
Pipeline: "deploy",
17+
Render: true,
18+
RenderWriter: os.Stdout,
1619
}
1720

1821
renderCmd := &cobra.Command{
@@ -32,6 +35,6 @@ deployment.
3235
},
3336
}
3437

35-
cmd.AddFlags(renderCmd, "deploy")
38+
cmd.AddFlags(renderCmd)
3639
return renderCmd
3740
}

cmd/run_pipeline.go

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -73,31 +73,34 @@ type RunPipelineCmd struct {
7373
log log.Logger
7474
}
7575

76-
func (cmd *RunPipelineCmd) AddFlags(command *cobra.Command, defaultPipeline string) {
77-
command.Flags().StringSliceVar(&cmd.SkipDependency, "skip-dependency", []string{}, "Skips the following dependencies for deployment")
78-
command.Flags().StringSliceVar(&cmd.Dependency, "dependency", []string{}, "Deploys only the specified named dependencies")
79-
80-
command.Flags().BoolVarP(&cmd.ForceBuild, "force-build", "b", false, "Forces to build every image")
81-
command.Flags().BoolVar(&cmd.SkipBuild, "skip-build", false, "Skips building of images")
82-
command.Flags().BoolVar(&cmd.BuildSequential, "build-sequential", false, "Builds the images one after another instead of in parallel")
83-
command.Flags().IntVar(&cmd.MaxConcurrentBuilds, "max-concurrent-builds", 0, "The maximum number of image builds built in parallel (0 for infinite)")
84-
command.Flags().BoolVar(&cmd.Render, "render", false, "If true will render manifests and print them instead of actually deploying them")
85-
86-
command.Flags().BoolVarP(&cmd.ForceDeploy, "force-deploy", "d", false, "Forces to deploy every deployment")
87-
command.Flags().BoolVar(&cmd.SkipDeploy, "skip-deploy", false, "If enabled will skip deploying")
88-
command.Flags().StringVar(&cmd.Pipeline, "pipeline", defaultPipeline, "The pipeline to execute")
89-
90-
command.Flags().StringSliceVarP(&cmd.Tags, "tag", "t", []string{}, "Use the given tag for all built images")
91-
command.Flags().BoolVar(&cmd.SkipPush, "skip-push", false, "Skips image pushing, useful for minikube deployment")
92-
command.Flags().BoolVar(&cmd.SkipPushLocalKubernetes, "skip-push-local-kube", true, "Skips image pushing, if a local kubernetes environment is detected")
93-
94-
command.Flags().BoolVarP(&cmd.Terminal, "terminal", "t", false, "Open a terminal instead of showing logs")
95-
command.Flags().BoolVar(&cmd.ShowUI, "show-ui", false, "Shows the ui server")
76+
func (cmd *RunPipelineCmd) AddFlags(command *cobra.Command) {
77+
command.Flags().StringSliceVar(&cmd.SkipDependency, "skip-dependency", cmd.SkipDependency, "Skips the following dependencies for deployment")
78+
command.Flags().StringSliceVar(&cmd.Dependency, "dependency", cmd.Dependency, "Deploys only the specified named dependencies")
79+
80+
command.Flags().BoolVarP(&cmd.ForceBuild, "force-build", "b", cmd.ForceBuild, "Forces to build every image")
81+
command.Flags().BoolVar(&cmd.SkipBuild, "skip-build", cmd.SkipBuild, "Skips building of images")
82+
command.Flags().BoolVar(&cmd.BuildSequential, "build-sequential", cmd.BuildSequential, "Builds the images one after another instead of in parallel")
83+
command.Flags().IntVar(&cmd.MaxConcurrentBuilds, "max-concurrent-builds", cmd.MaxConcurrentBuilds, "The maximum number of image builds built in parallel (0 for infinite)")
84+
command.Flags().BoolVar(&cmd.Render, "render", cmd.Render, "If true will render manifests and print them instead of actually deploying them")
85+
86+
command.Flags().BoolVarP(&cmd.ForceDeploy, "force-deploy", "d", cmd.ForceDeploy, "Forces to deploy every deployment")
87+
command.Flags().BoolVar(&cmd.SkipDeploy, "skip-deploy", cmd.SkipDeploy, "If enabled will skip deploying")
88+
command.Flags().StringVar(&cmd.Pipeline, "pipeline", cmd.Pipeline, "The pipeline to execute")
89+
90+
command.Flags().StringSliceVarP(&cmd.Tags, "tag", "t", cmd.Tags, "Use the given tag for all built images")
91+
command.Flags().BoolVar(&cmd.SkipPush, "skip-push", cmd.SkipPush, "Skips image pushing, useful for minikube deployment")
92+
command.Flags().BoolVar(&cmd.SkipPushLocalKubernetes, "skip-push-local-kube", cmd.SkipPushLocalKubernetes, "Skips image pushing, if a local kubernetes environment is detected")
93+
94+
command.Flags().BoolVarP(&cmd.Terminal, "terminal", "t", cmd.Terminal, "Open a terminal instead of showing logs")
95+
command.Flags().BoolVar(&cmd.ShowUI, "show-ui", cmd.ShowUI, "Shows the ui server")
9696
}
9797

9898
// NewRunPipelineCmd creates a new devspace run-pipeline command
9999
func NewRunPipelineCmd(f factory.Factory, globalFlags *flags.GlobalFlags) *cobra.Command {
100-
cmd := &RunPipelineCmd{GlobalFlags: globalFlags}
100+
cmd := &RunPipelineCmd{
101+
GlobalFlags: globalFlags,
102+
SkipPushLocalKubernetes: true,
103+
}
101104
runPipelineCmd := &cobra.Command{
102105
Use: "run-pipeline",
103106
Short: "Starts the development mode",
@@ -121,7 +124,7 @@ Execute a pipeline
121124
},
122125
}
123126

124-
cmd.AddFlags(runPipelineCmd, "")
127+
cmd.AddFlags(runPipelineCmd)
125128
return runPipelineCmd
126129
}
127130

0 commit comments

Comments
 (0)