diff --git a/cmd/apply.go b/cmd/apply.go index 01dc8f67..7e71482b 100644 --- a/cmd/apply.go +++ b/cmd/apply.go @@ -30,7 +30,7 @@ func NewApplyCmd(globalCfg *config.GlobalImpl) *cobra.Command { } f := cmd.Flags() - f.StringSliceVar(&applyImpl.ApplyOptions.Values, "values", []string{}, "additional value files to be merged into the command") + f.StringSliceVar(&applyImpl.ApplyOptions.Values, "values", nil, "additional value files to be merged into the command") f.IntVar(&applyImpl.ApplyOptions.Concurrency, "concurrency", 0, "maximum number of concurrent helm processes to run, 0 is unlimited") f.BoolVar(&applyImpl.ApplyOptions.Validate, "validate", false, "validate your manifests against the Kubernetes cluster you are currently pointing at. Note that this requires access to a Kubernetes cluster to obtain information necessary for validating, like the list of available API versions") f.IntVar(&applyImpl.ApplyOptions.Context, "context", 0, "output NUM lines of context around changes") @@ -45,7 +45,7 @@ func NewApplyCmd(globalCfg *config.GlobalImpl) *cobra.Command { f.BoolVar(&applyImpl.ApplyOptions.IncludeTransitiveNeeds, "include-transitive-needs", false, `like --include-needs, but also includes transitive needs (needs of needs). Does nothing when when --selector/-l flag is not provided. Overrides exclusions of other selectors and conditions.`) f.BoolVar(&applyImpl.ApplyOptions.SkipDiffOnInstall, "skip-diff-on-install", false, "Skips running helm-diff on releases being newly installed on this apply. Useful when the release manifests are too huge to be reviewed, or it's too time-consuming to diff at all0") f.BoolVar(&applyImpl.ApplyOptions.IncludeTests, "include-tests", false, "enable the diffing of the helm test hooks") - f.StringArrayVar(&applyImpl.ApplyOptions.Suppress, "suppress", []string{}, "suppress specified Kubernetes objects in the diff output. Can be provided multiple times. For example: --suppress KeycloakClient --suppress VaultSecret") + f.StringArrayVar(&applyImpl.ApplyOptions.Suppress, "suppress", nil, "suppress specified Kubernetes objects in the diff output. Can be provided multiple times. For example: --suppress KeycloakClient --suppress VaultSecret") f.BoolVar(&applyImpl.ApplyOptions.SuppressSecrets, "suppress-secrets", false, "suppress secrets in the diff output. highly recommended to specify on CI/CD use-cases") f.BoolVar(&applyImpl.ApplyOptions.ShowSecrets, "show-secrets", false, "do not redact secret values in the diff output. should be used for debug purpose only") f.BoolVar(&applyImpl.ApplyOptions.SuppressDiff, "suppress-diff", false, "suppress diff in the output. Usable in new installs") diff --git a/cmd/charts.go b/cmd/charts.go index 9ad0e08b..5e9457f7 100644 --- a/cmd/charts.go +++ b/cmd/charts.go @@ -30,9 +30,9 @@ func NewChartsCmd(globalCfg *config.GlobalImpl) *cobra.Command { } f := cmd.Flags() - f.StringVar(&chartsOptions.Args, "args", chartsOptions.Args, "pass args to helm exec") - f.StringArrayVar(&chartsOptions.Set, "set", chartsOptions.Set, "additional values to be merged into the command") - f.StringArrayVar(&chartsOptions.Values, "values", chartsOptions.Values, "additional value files to be merged into the command") + f.StringVar(&chartsOptions.Args, "args", "", "pass args to helm exec") + f.StringArrayVar(&chartsOptions.Set, "set", nil, "additional values to be merged into the command") + f.StringArrayVar(&chartsOptions.Values, "values", nil, "additional value files to be merged into the command") f.IntVar(&chartsOptions.Concurrency, "concurrency", 0, "maximum number of concurrent helm processes to run, 0 is unlimited") return cmd diff --git a/cmd/delete.go b/cmd/delete.go index 26cbad75..89ab2aa8 100644 --- a/cmd/delete.go +++ b/cmd/delete.go @@ -30,10 +30,10 @@ func NewDeleteCmd(globalCfg *config.GlobalImpl) *cobra.Command { } f := cmd.Flags() - f.StringVar(&deleteOptions.Args, "args", deleteOptions.Args, "pass args to helm exec") + f.StringVar(&deleteOptions.Args, "args", "", "pass args to helm exec") f.IntVar(&deleteOptions.Concurrency, "concurrency", 0, "maximum number of concurrent helm processes to run, 0 is unlimited") - f.BoolVar(&deleteOptions.Purge, "purge", deleteOptions.Purge, "purge releases i.e. free release names and histories") - f.BoolVar(&deleteOptions.SkipDeps, "skip-deps", deleteOptions.SkipDeps, `skip running "helm repo update" and "helm dependency build"`) + f.BoolVar(&deleteOptions.Purge, "purge", false, "purge releases i.e. free release names and histories") + f.BoolVar(&deleteOptions.SkipDeps, "skip-deps", false, `skip running "helm repo update" and "helm dependency build"`) return cmd } diff --git a/cmd/deps.go b/cmd/deps.go index 6018f1fe..690e4b8d 100644 --- a/cmd/deps.go +++ b/cmd/deps.go @@ -30,8 +30,8 @@ func NewDepsCmd(globalCfg *config.GlobalImpl) *cobra.Command { } f := cmd.Flags() - f.StringVar(&depsOptions.Args, "args", depsOptions.Args, "pass args to helm exec") - f.BoolVar(&depsOptions.SkipRepos, "skip-deps", depsOptions.SkipRepos, `skip running "helm repo update" and "helm dependency build"`) + f.StringVar(&depsOptions.Args, "args", "", "pass args to helm exec") + f.BoolVar(&depsOptions.SkipRepos, "skip-deps", false, `skip running "helm repo update" and "helm dependency build"`) return cmd } diff --git a/cmd/destroy.go b/cmd/destroy.go index 50a5a314..523d9706 100644 --- a/cmd/destroy.go +++ b/cmd/destroy.go @@ -30,9 +30,9 @@ func NewDestroyCmd(globalCfg *config.GlobalImpl) *cobra.Command { } f := cmd.Flags() - f.StringVar(&destroyOptions.Args, "args", destroyOptions.Args, "pass args to helm exec") + f.StringVar(&destroyOptions.Args, "args", "", "pass args to helm exec") f.IntVar(&destroyOptions.Concurrency, "concurrency", 0, "maximum number of concurrent helm processes to run, 0 is unlimited") - f.BoolVar(&destroyOptions.SkipDeps, "skip-deps", destroyOptions.SkipDeps, `skip running "helm repo update" and "helm dependency build"`) + f.BoolVar(&destroyOptions.SkipDeps, "skip-deps", false, `skip running "helm repo update" and "helm dependency build"`) return cmd } diff --git a/cmd/diff.go b/cmd/diff.go index 9a168e53..5633db1e 100644 --- a/cmd/diff.go +++ b/cmd/diff.go @@ -31,8 +31,8 @@ func NewDiffCmd(globalCfg *config.GlobalImpl) *cobra.Command { f := cmd.Flags() f.StringVar(&diffOptions.Args, "args", "", "pass args to helm diff") - f.StringArrayVar(&diffOptions.Set, "set", []string{}, "additional values to be merged into the command") - f.StringArrayVar(&diffOptions.Values, "values", []string{}, "additional value files to be merged into the command") + f.StringArrayVar(&diffOptions.Set, "set", nil, "additional values to be merged into the command") + f.StringArrayVar(&diffOptions.Values, "values", nil, "additional value files to be merged into the command") f.IntVar(&diffOptions.Concurrency, "concurrency", 0, "maximum number of concurrent downloads of release charts") f.BoolVar(&diffOptions.Validate, "validate", false, "validate your manifests against the Kubernetes cluster you are currently pointing at. Note that this requires access to a Kubernetes cluster to obtain information necessary for validating, like the diff of available API versions") f.BoolVar(&diffOptions.SkipNeeds, "skip-needs", false, `do not automatically include releases from the target release's "needs" when --selector/-l flag is provided. Does nothing when when --selector/-l flag is not provided. Defaults to true when --include-needs or --include-transitive-needs is not provided`) @@ -46,7 +46,7 @@ func NewDiffCmd(globalCfg *config.GlobalImpl) *cobra.Command { f.IntVar(&diffOptions.Context, "context", 0, "output NUM lines of context around changes") f.StringVar(&diffOptions.Output, "output", "", "output format for diff plugin") f.BoolVar(&diffOptions.SuppressSecrets, "suppress-secrets", false, "suppress secrets in the output. highly recommended to specify on CI/CD use-cases") - f.StringArrayVar(&diffOptions.Suppress, "suppress", []string{}, "suppress specified Kubernetes objects in the output. Can be provided multiple times. For example: --suppress KeycloakClient --suppress VaultSecret") + f.StringArrayVar(&diffOptions.Suppress, "suppress", nil, "suppress specified Kubernetes objects in the output. Can be provided multiple times. For example: --suppress KeycloakClient --suppress VaultSecret") return cmd } diff --git a/cmd/fetch.go b/cmd/fetch.go index fb21703d..8c4bcb0b 100644 --- a/cmd/fetch.go +++ b/cmd/fetch.go @@ -31,8 +31,8 @@ func NewFetchCmd(globalCfg *config.GlobalImpl) *cobra.Command { f := cmd.Flags() f.IntVar(&fetchOptions.Concurrency, "concurrency", 0, "maximum number of concurrent helm processes to run, 0 is unlimited") - f.BoolVar(&fetchOptions.SkipDeps, "skip-deps", fetchOptions.SkipDeps, `skip running "helm repo update" and "helm dependency build"`) - f.StringVar(&fetchOptions.OutputDir, "output-dir", fetchOptions.OutputDir, "directory to store charts (default: temporary directory which is deleted when the command terminates)") + f.BoolVar(&fetchOptions.SkipDeps, "skip-deps", false, `skip running "helm repo update" and "helm dependency build"`) + f.StringVar(&fetchOptions.OutputDir, "output-dir", "", "directory to store charts (default: temporary directory which is deleted when the command terminates)") return cmd } diff --git a/cmd/list.go b/cmd/list.go index 8ed6248c..63d1c95b 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -30,8 +30,8 @@ func NewListCmd(globalCfg *config.GlobalImpl) *cobra.Command { } f := cmd.Flags() - f.BoolVar(&listOptions.KeepTempDir, "keep-temp-dir", listOptions.KeepTempDir, "Keep temporary directory") - f.StringVar(&listOptions.Output, "output", listOptions.Output, "output releases list as a json string") + f.BoolVar(&listOptions.KeepTempDir, "keep-temp-dir", false, "Keep temporary directory") + f.StringVar(&listOptions.Output, "output", "", "output releases list as a json string") return cmd } diff --git a/cmd/repos.go b/cmd/repos.go index 0940f005..2d3563a6 100644 --- a/cmd/repos.go +++ b/cmd/repos.go @@ -30,7 +30,7 @@ func NewReposCmd(globalCfg *config.GlobalImpl) *cobra.Command { } f := cmd.Flags() - f.StringVar(&reposOptions.Args, "args", reposOptions.Args, "pass args to helm exec") + f.StringVar(&reposOptions.Args, "args", "", "pass args to helm exec") return cmd } diff --git a/cmd/root.go b/cmd/root.go index ae6c34dd..e88a0e4d 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -103,24 +103,24 @@ func NewRootCmd(globalConfig *config.GlobalOptions, args []string) (*cobra.Comma func setGlobalOptionsForRootCmd(fs *pflag.FlagSet, globalOptions *config.GlobalOptions) { fs.StringVarP(&globalOptions.HelmBinary, "helm-binary", "b", app.DefaultHelmBinary, "Path to the helm binary") - fs.StringVarP(&globalOptions.File, "file", "f", globalOptions.File, "load config from file or directory. defaults to `helmfile.yaml` or `helmfile.d`(means `helmfile.d/*.yaml`) in this preference") - fs.StringVarP(&globalOptions.Environment, "environment", "e", globalOptions.Environment, `specify the environment name. defaults to "default"`) - fs.StringArrayVarP(&globalOptions.StateValuesSet, "state-values-set", "s", globalOptions.StateValuesSet, "set state values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)") - fs.StringArrayVarP(&globalOptions.StateValuesFile, "state-values-file", "", globalOptions.StateValuesFile, "specify state values in a YAML file") - fs.BoolVarP(&globalOptions.Quiet, "quiet", "q", globalOptions.Quiet, "Silence output. Equivalent to log-level warn") - fs.StringVar(&globalOptions.KubeContext, "kube-context", globalOptions.KubeContext, "Set kubectl context. Uses current context by default") - fs.BoolVar(&globalOptions.Debug, "debug", globalOptions.Debug, "Enable verbose output for Helm and set log-level to debug, this disables --quiet/-q effect") - fs.BoolVar(&globalOptions.Color, "color", globalOptions.Color, "Output with color") - fs.BoolVar(&globalOptions.NoColor, "no-color", globalOptions.NoColor, "Output without color") - fs.StringVar(&globalOptions.LogLevel, "log-level", globalOptions.LogLevel, "Set log level, default info") - fs.StringVar(&globalOptions.Namespace, "namespace", globalOptions.Namespace, "Set namespace. Uses the namespace set in the context by default, and is available in templates as {{ .Namespace }}") - fs.StringVar(&globalOptions.Chart, "chart", globalOptions.Chart, "Set chart. Uses the chart set in release by default, and is available in template as {{ .Chart }}") - fs.StringArrayVarP(&globalOptions.Selector, "selector", "l", globalOptions.Selector, `Only run using the releases that match labels. Labels can take the form of foo=bar or foo!=bar. + fs.StringVarP(&globalOptions.File, "file", "f", "", "load config from file or directory. defaults to `helmfile.yaml` or `helmfile.d`(means `helmfile.d/*.yaml`) in this preference") + fs.StringVarP(&globalOptions.Environment, "environment", "e", "", `specify the environment name. defaults to "default"`) + fs.StringArrayVarP(&globalOptions.StateValuesSet, "state-values-set", "s", nil, "set state values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)") + fs.StringArrayVarP(&globalOptions.StateValuesFile, "state-values-file", "", nil, "specify state values in a YAML file") + fs.BoolVarP(&globalOptions.Quiet, "quiet", "q", false, "Silence output. Equivalent to log-level warn") + fs.StringVar(&globalOptions.KubeContext, "kube-context", "", "Set kubectl context. Uses current context by default") + fs.BoolVar(&globalOptions.Debug, "debug", false, "Enable verbose output for Helm and set log-level to debug, this disables --quiet/-q effect") + fs.BoolVar(&globalOptions.Color, "color", false, "Output with color") + fs.BoolVar(&globalOptions.NoColor, "no-color", false, "Output without color") + fs.StringVar(&globalOptions.LogLevel, "log-level", "info", "Set log level, default info") + fs.StringVar(&globalOptions.Namespace, "namespace", "", "Set namespace. Uses the namespace set in the context by default, and is available in templates as {{ .Namespace }}") + fs.StringVar(&globalOptions.Chart, "chart", "", "Set chart. Uses the chart set in release by default, and is available in template as {{ .Chart }}") + fs.StringArrayVarP(&globalOptions.Selector, "selector", "l", nil, `Only run using the releases that match labels. Labels can take the form of foo=bar or foo!=bar. A release must match all labels in a group in order to be used. Multiple groups can be specified at once. --selector tier=frontend,tier!=proxy --selector tier=backend. Will match all frontend, non-proxy releases AND all backend releases. The name of a release can be used as a label. --selector name=myrelease`) - fs.BoolVar(&globalOptions.AllowNoMatchingRelease, "allow-no-matching-release", globalOptions.AllowNoMatchingRelease, `Do not exit with an error code if the provided selector has no matching releases.`) - fs.BoolVarP(&globalOptions.Interactive, "interactive", "i", globalOptions.Interactive, "Request confirmation before attempting to modify clusters") + fs.BoolVar(&globalOptions.AllowNoMatchingRelease, "allow-no-matching-release", false, `Do not exit with an error code if the provided selector has no matching releases.`) + fs.BoolVarP(&globalOptions.Interactive, "interactive", "i", false, "Request confirmation before attempting to modify clusters") // avoid 'pflag: help requested' error (#251) fs.BoolP("help", "h", false, "help for helmfile") } diff --git a/cmd/status.go b/cmd/status.go index d9f5f2c3..1414ce60 100644 --- a/cmd/status.go +++ b/cmd/status.go @@ -30,7 +30,7 @@ func NewStatusCmd(globalCfg *config.GlobalImpl) *cobra.Command { } f := cmd.Flags() - f.StringVar(&statusOptions.Args, "args", statusOptions.Args, "pass args to helm exec") + f.StringVar(&statusOptions.Args, "args", "", "pass args to helm exec") return cmd } diff --git a/cmd/sync.go b/cmd/sync.go index 2fe481b8..95e7930b 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -31,8 +31,8 @@ func NewSyncCmd(globalCfg *config.GlobalImpl) *cobra.Command { f := cmd.Flags() f.StringVar(&syncOptions.Args, "args", "", "pass args to helm sync") - f.StringArrayVar(&syncOptions.Set, "set", []string{}, "additional values to be merged into the command") - f.StringArrayVar(&syncOptions.Values, "values", []string{}, "additional value files to be merged into the command") + f.StringArrayVar(&syncOptions.Set, "set", nil, "additional values to be merged into the command") + f.StringArrayVar(&syncOptions.Values, "values", nil, "additional value files to be merged into the command") f.IntVar(&syncOptions.Concurrency, "concurrency", 0, "maximum number of concurrent downloads of release charts") f.BoolVar(&syncOptions.Validate, "validate", false, "validate your manifests against the Kubernetes cluster you are currently pointing at. Note that this requires access to a Kubernetes cluster to obtain information necessary for validating, like the sync of available API versions") f.BoolVar(&syncOptions.SkipNeeds, "skip-needs", false, `do not automatically include releases from the target release's "needs" when --selector/-l flag is provided. Does nothing when when --selector/-l flag is not provided. Defaults to true when --include-needs or --include-transitive-needs is not provided`) diff --git a/cmd/template.go b/cmd/template.go index 9b821d3b..384fa305 100644 --- a/cmd/template.go +++ b/cmd/template.go @@ -31,8 +31,8 @@ func NewTemplateCmd(globalCfg *config.GlobalImpl) *cobra.Command { f := cmd.Flags() f.StringVar(&templateOptions.Args, "args", "", "pass args to helm template") - f.StringArrayVar(&templateOptions.Set, "set", []string{}, "additional values to be merged into the command") - f.StringArrayVar(&templateOptions.Values, "values", []string{}, "additional value files to be merged into the command") + f.StringArrayVar(&templateOptions.Set, "set", nil, "additional values to be merged into the command") + f.StringArrayVar(&templateOptions.Values, "values", nil, "additional value files to be merged into the command") f.StringVar(&templateOptions.OutputDir, "output-dir", "", "output directory to pass to helm template (helm template --output-dir)") f.StringVar(&templateOptions.OutputDirTemplate, "output-dir-template", "", "go text template for generating the output directory. Default: {{ .OutputDir }}/{{ .State.BaseName }}-{{ .State.AbsPathSHA1 }}-{{ .Release.Name}}") f.IntVar(&templateOptions.Concurrency, "concurrency", 0, "maximum number of concurrent downloads of release charts") diff --git a/cmd/test.go b/cmd/test.go index 0af5cf10..efd466b7 100644 --- a/cmd/test.go +++ b/cmd/test.go @@ -32,10 +32,10 @@ func NewTestCmd(globalCfg *config.GlobalImpl) *cobra.Command { f := cmd.Flags() f.IntVar(&testOptions.Concurrency, "concurrency", 0, "maximum number of concurrent downloads of release charts") - f.BoolVar(&testOptions.SkipDeps, "skip-deps", testOptions.SkipDeps, `skip running "helm repo update" and "helm dependency build"`) - f.BoolVar(&testOptions.Cleanup, "cleanup", testOptions.Cleanup, "delete test pods upon completion") - f.BoolVar(&testOptions.Logs, "logs", testOptions.Logs, "Dump the logs from test pods (this runs after all tests are complete, but before any cleanup)") - f.StringVar(&testOptions.Args, "args", testOptions.Args, "pass args to helm exec") + f.BoolVar(&testOptions.SkipDeps, "skip-deps", false, `skip running "helm repo update" and "helm dependency build"`) + f.BoolVar(&testOptions.Cleanup, "cleanup", false, "delete test pods upon completion") + f.BoolVar(&testOptions.Logs, "logs", false, "Dump the logs from test pods (this runs after all tests are complete, but before any cleanup)") + f.StringVar(&testOptions.Args, "args", "", "pass args to helm exec") f.IntVar(&testOptions.Timeout, "timeout", 300, "maximum time for tests to run before being considered failed") return cmd diff --git a/cmd/write-values.go b/cmd/write-values.go index 8c918fa9..f00c624d 100644 --- a/cmd/write-values.go +++ b/cmd/write-values.go @@ -31,10 +31,10 @@ func NewWriteValuesCmd(globalCfg *config.GlobalImpl) *cobra.Command { f := cmd.Flags() f.IntVar(&writeValuesOptions.Concurrency, "concurrency", 0, "maximum number of concurrent downloads of release charts") - f.BoolVar(&writeValuesOptions.SkipDeps, "skip-deps", writeValuesOptions.SkipDeps, `skip running "helm repo update" and "helm dependency build"`) - f.StringArrayVar(&writeValuesOptions.Set, "set", writeValuesOptions.Set, "additional values to be merged into the command") - f.StringArrayVar(&writeValuesOptions.Values, "values", writeValuesOptions.Values, "additional value files to be merged into the command") - f.StringVar(&writeValuesOptions.OutputFileTemplate, "output-file-template", writeValuesOptions.OutputFileTemplate, "go text template for generating the output file. Default: {{ .State.BaseName }}-{{ .State.AbsPathSHA1 }}/{{ .Release.Name}}.yaml") + f.BoolVar(&writeValuesOptions.SkipDeps, "skip-deps", false, `skip running "helm repo update" and "helm dependency build"`) + f.StringArrayVar(&writeValuesOptions.Set, "set", nil, "additional values to be merged into the command") + f.StringArrayVar(&writeValuesOptions.Values, "values", nil, "additional value files to be merged into the command") + f.StringVar(&writeValuesOptions.OutputFileTemplate, "output-file-template", "", "go text template for generating the output file. Default: {{ .State.BaseName }}-{{ .State.AbsPathSHA1 }}/{{ .Release.Name}}.yaml") return cmd }