Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --force command line option to run and deploy sub-commands #1568

Merged
merged 1 commit into from
Apr 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.Force, "force", false, "Recreate kubernetes resources if necessary for deployment (default: false, 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 @@ -331,6 +331,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 for deployment (default: false, warning: might cause downtime!)
--images strings A list of pre-built images to deploy
--insecure-registry stringArray Target registries for built images which are not secure
-l, --label stringArray Add custom labels to deployed objects. Set multiple times for multiple labels.
Expand All @@ -356,6 +357,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_INSECURE_REGISTRY` (same as `--insecure-registry`)
* `SKAFFOLD_LABEL` (same as `--label`)
Expand Down Expand Up @@ -521,6 +523,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 for deployment (default: false, warning: might cause downtime!)
--insecure-registry stringArray Target registries for built images which are not secure
-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 @@ -546,6 +549,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_INSECURE_REGISTRY` (same as `--insecure-registry`)
* `SKAFFOLD_LABEL` (same as `--label`)
* `SKAFFOLD_NAMESPACE` (same as `--namespace`)
Expand Down
5 changes: 5 additions & 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
Force bool
NoPrune bool
CustomTag string
Namespace string
Expand Down Expand Up @@ -90,3 +91,7 @@ func (opts *SkaffoldOptions) Labels() map[string]string {
func (opts *SkaffoldOptions) Prune() bool {
return !opts.NoPrune && !opts.CacheArtifacts
}

func (opts *SkaffoldOptions) ForceDeploy() bool {
return opts.Command == "dev" || opts.Force
}
5 changes: 5 additions & 0 deletions pkg/skaffold/deploy/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type HelmDeployer struct {
kubeContext string
namespace string
defaultRepo string
forceDeploy bool
}

// NewHelmDeployer returns a new HelmDeployer for a DeployConfig filled
Expand All @@ -58,6 +59,7 @@ func NewHelmDeployer(runCtx *runcontext.RunContext) *HelmDeployer {
kubeContext: runCtx.KubeContext,
namespace: runCtx.Opts.Namespace,
defaultRepo: runCtx.DefaultRepo,
forceDeploy: runCtx.Opts.ForceDeploy(),
}
}

Expand Down Expand Up @@ -190,6 +192,9 @@ func (h *HelmDeployer) deployRelease(ctx context.Context, out io.Writer, r lates
} else {
args = append(args, "upgrade", releaseName)
args = append(args, h.Flags.Upgrade...)
if h.forceDeploy {
args = append(args, "--force")
}
if r.RecreatePods {
args = append(args, "--recreate-pods")
}
Expand Down
Loading