Signed-off-by: George Jenkins <gjenkins8@bloomberg.net>
pull/11744/head
George Jenkins 3 years ago
parent 27c6a8c1cf
commit 4a40e1c9ab

@ -124,11 +124,9 @@ charts in a repository, use 'helm search'.
func determineDryRunMode(dryRunModeFlag string) (*action.DryRunMode, error) { func determineDryRunMode(dryRunModeFlag string) (*action.DryRunMode, error) {
switch dryRunModeFlag { switch dryRunModeFlag {
case "none": case "none", "false": // TODO: Remove "false" helm v4
case "false": // TODO: Remove "false" helm v4
return &action.DryRunModeNone, nil return &action.DryRunModeNone, nil
case "client": case "client", "unspecified", "true": // TODO: Remove "true" helm v4
case "true": // TODO: Remove "true" helm v4
return &action.DryRunModeClient, nil return &action.DryRunModeClient, nil
case "server": case "server":
return &action.DryRunModeServer, nil 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) bindOutputFlag(cmd, &outfmt)
bindPostRenderFlag(cmd, &client.PostRenderer) bindPostRenderFlag(cmd, &client.PostRenderer)
return cmd 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.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.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.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") 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")

@ -48,19 +48,16 @@ faked locally. Additionally, none of the server-side testing of chart validity
func determineTemplateDryRunMode(dryRunModeFlag string) (*action.DryRunMode, error) { func determineTemplateDryRunMode(dryRunModeFlag string) (*action.DryRunMode, error) {
switch dryRunModeFlag { switch dryRunModeFlag {
case "none":
return nil, fmt.Errorf("Invalid flag --dry-run=none for template")
case "false": // TODO: Remove "false" helm v4 case "false": // TODO: Remove "false" helm v4
// helm template --dry-run=false was previously ignored, and dry-run set anyway // helm template --dry-run=false was previously ignored, and dry-run set anyway
return &action.DryRunModeClient, nil return &action.DryRunModeClient, nil
case "client": case "unspecified", "client", "true": // TODO: Remove "true" helm v4
case "true": // TODO: Remove "true" helm v4
return &action.DryRunModeClient, nil return &action.DryRunModeClient, nil
case "server": case "server":
return &action.DryRunModeServer, nil 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 { 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() 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.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.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") 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")

Loading…
Cancel
Save