diff --git a/cmd/helm/install.go b/cmd/helm/install.go index 658842390..75a0d8067 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -124,11 +124,9 @@ charts in a repository, use 'helm search'. func determineDryRunMode(dryRunModeFlag string) (*action.DryRunMode, error) { switch dryRunModeFlag { - case "none": - case "false": // TODO: Remove "false" helm v4 + case "none", "false": // TODO: Remove "false" helm v4 return &action.DryRunModeNone, nil - case "client": - case "true": // TODO: Remove "true" helm v4 + case "client", "unspecified", "true": // TODO: Remove "true" helm v4 return &action.DryRunModeClient, nil case "server": return &action.DryRunModeServer, nil @@ -170,21 +168,24 @@ func newInstallCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { }, } - addInstallFlags(cmd, cmd.Flags(), client, &dryRunModeFlag, valueOpts) + f := cmd.Flags() + addInstallFlags(cmd, f, client, valueOpts) + f.StringVar( + &dryRunModeFlag, + "dry-run", + "none", + `simulate an install. Must be "none", "server", or "client". If client strategy, X. If server strategy, Y. For backwards compatibility, boolean values "true" and "false" are also accepted. "true" being a synonym for "client". "false" meaning disable dry-run`, + ) + f.Lookup("dry-run").NoOptDefVal = "unspecified" + bindOutputFlag(cmd, &outfmt) bindPostRenderFlag(cmd, &client.PostRenderer) return cmd } -func addInstallFlags(cmd *cobra.Command, f *pflag.FlagSet, client *action.Install, dryRunModeFlag *string, valueOpts *values.Options) { +func addInstallFlags(cmd *cobra.Command, f *pflag.FlagSet, client *action.Install, valueOpts *values.Options) { f.BoolVar(&client.CreateNamespace, "create-namespace", false, "create the release namespace if not present") - f.StringVar( - dryRunModeFlag, - "dry-run", - "none", - `simulate an install. Must be "none", "server", or "client". If client strategy, X. If server strategy, Y. For backwards compatibility, boolean values "true" and "false" are also accepted. "true" being a synonym for "client". "false" meaning disable dry-run`, - ) f.BoolVar(&client.Force, "force", false, "force resource updates through a replacement strategy") f.BoolVar(&client.DisableHooks, "no-hooks", false, "prevent hooks from running during install") f.BoolVar(&client.Replace, "replace", false, "re-use the given name, only if that name is a deleted release which remains in the history. This is unsafe in production") diff --git a/cmd/helm/template.go b/cmd/helm/template.go index 836bc0e2b..8e7d53f5f 100644 --- a/cmd/helm/template.go +++ b/cmd/helm/template.go @@ -48,19 +48,16 @@ faked locally. Additionally, none of the server-side testing of chart validity func determineTemplateDryRunMode(dryRunModeFlag string) (*action.DryRunMode, error) { switch dryRunModeFlag { - case "none": - return nil, fmt.Errorf("Invalid flag --dry-run=none for template") case "false": // TODO: Remove "false" helm v4 // helm template --dry-run=false was previously ignored, and dry-run set anyway return &action.DryRunModeClient, nil - case "client": - case "true": // TODO: Remove "true" helm v4 + case "unspecified", "client", "true": // TODO: Remove "true" helm v4 return &action.DryRunModeClient, nil case "server": return &action.DryRunModeServer, nil } - return nil, fmt.Errorf("Invalid --dry-run flag value: %s", dryRunModeFlag) + return nil, fmt.Errorf("Invalid --dry-run flag value: '%s'", dryRunModeFlag) } func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { @@ -196,7 +193,14 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { } f := cmd.Flags() - addInstallFlags(cmd, f, client, &dryRunModeFlag, valueOpts) + addInstallFlags(cmd, f, client, valueOpts) + f.StringVar( + &dryRunModeFlag, + "dry-run", + "client", + `install simulation mode for templating. Must be "server", or "client". If client strategy, X. If server strategy, Y`, + ) + f.Lookup("dry-run").NoOptDefVal = "unspecified" f.StringArrayVarP(&showFiles, "show-only", "s", []string{}, "only show manifests rendered from the given templates") f.StringVar(&client.OutputDir, "output-dir", "", "writes the executed templates to files in output-dir instead of stdout") f.BoolVar(&validate, "validate", false, "validate your manifests against the Kubernetes cluster you are currently pointing at. This is the same validation performed on an install")