Skip to content

Commit

Permalink
Add new flag '--force' to run/deploy commands
Browse files Browse the repository at this point in the history
This flag controls, if resources may be re-created, if patching is not possible.

Signed-off-by: Cornelius Weig <22861411+corneliusweig@users.noreply.github.com>
  • Loading branch information
corneliusweig committed Apr 1, 2019
1 parent 0c7f59c commit 78bc86e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions cmd/skaffold/app/cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ func FlagToEnvVarName(f *pflag.Flag) string {

func AddRunDeployFlags(cmd *cobra.Command) {
cmd.Flags().BoolVar(&opts.Tail, "tail", false, "Stream logs from deployed objects")
cmd.Flags().BoolVar(&opts.ForceDeploy, "force", false, "Recreate kubernetes resources if necessary during deployment (warning: might cause downtime!)")
cmd.Flags().StringArrayVarP(&opts.CustomLabels, "label", "l", nil, "Add custom labels to deployed objects. Set multiple times for multiple labels.")
}

Expand Down
4 changes: 4 additions & 0 deletions docs/content/en/docs/references/cli/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ Flags:
-d, --default-repo string Default repository value (overrides global config)
--enable-rpc skaffold dev Enable gRPC for exposing Skaffold events (true by default for skaffold dev)
-f, --filename string Filename or URL to the pipeline file (default "skaffold.yaml")
--force Recreate kubernetes resources if necessary during deployment (warning: might cause downtime!)
--images strings A list of pre-built images to deploy
-l, --label stringArray Add custom labels to deployed objects. Set multiple times for multiple labels.
-n, --namespace string Run deployments in the specified namespace
Expand All @@ -342,6 +343,7 @@ Env vars:
* `SKAFFOLD_DEFAULT_REPO` (same as `--default-repo`)
* `SKAFFOLD_ENABLE_RPC` (same as `--enable-rpc`)
* `SKAFFOLD_FILENAME` (same as `--filename`)
* `SKAFFOLD_FORCE` (same as `--force`)
* `SKAFFOLD_IMAGES` (same as `--images`)
* `SKAFFOLD_LABEL` (same as `--label`)
* `SKAFFOLD_NAMESPACE` (same as `--namespace`)
Expand Down Expand Up @@ -501,6 +503,7 @@ Flags:
-d, --default-repo string Default repository value (overrides global config)
--enable-rpc skaffold dev Enable gRPC for exposing Skaffold events (true by default for skaffold dev)
-f, --filename string Filename or URL to the pipeline file (default "skaffold.yaml")
--force Recreate kubernetes resources if necessary during deployment (warning: might cause downtime!)
-l, --label stringArray Add custom labels to deployed objects. Set multiple times for multiple labels.
-n, --namespace string Run deployments in the specified namespace
-p, --profile stringArray Activate profiles by name
Expand All @@ -524,6 +527,7 @@ Env vars:
* `SKAFFOLD_DEFAULT_REPO` (same as `--default-repo`)
* `SKAFFOLD_ENABLE_RPC` (same as `--enable-rpc`)
* `SKAFFOLD_FILENAME` (same as `--filename`)
* `SKAFFOLD_FORCE` (same as `--force`)
* `SKAFFOLD_LABEL` (same as `--label`)
* `SKAFFOLD_NAMESPACE` (same as `--namespace`)
* `SKAFFOLD_PROFILE` (same as `--profile`)
Expand Down
1 change: 1 addition & 0 deletions pkg/skaffold/config/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type SkaffoldOptions struct {
CacheArtifacts bool
ExperimentalGUI bool
EnableRPC bool
ForceDeploy bool
Profiles []string
CustomTag string
Namespace string
Expand Down
3 changes: 2 additions & 1 deletion pkg/skaffold/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ func NewForConfig(opts *config.SkaffoldOptions, cfg *latest.SkaffoldPipeline) (*
return nil, errors.Wrap(err, "parsing test config")
}

deployer, err := getDeployer(&cfg.Deploy, kubeContext, opts.Namespace, true, defaultRepo)
forceDeploy := opts.Command == "dev" || opts.ForceDeploy
deployer, err := getDeployer(&cfg.Deploy, kubeContext, opts.Namespace, forceDeploy, defaultRepo)
if err != nil {
return nil, errors.Wrap(err, "parsing deploy config")
}
Expand Down

0 comments on commit 78bc86e

Please sign in to comment.