diff --git a/cmd/helm/install.go b/cmd/helm/install.go index c3555fd05..57d70cabf 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -263,7 +263,7 @@ func runInstall(args []string, client *action.Install, valueOpts *values.Options client.Namespace = settings.Namespace() // validate dry-run flag value is one of the allowed values - if err := validateDryRunFlag(client); err != nil { + if err := validateDryRunFlag(client.DryRun); err != nil { return nil, err } @@ -308,12 +308,12 @@ func compInstall(args []string, toComplete string, client *action.Install) ([]st return nil, cobra.ShellCompDirectiveNoFileComp } -func validateDryRunFlag(client *action.Install) error { +func validateDryRunFlag(dryRunFlagValue string) error { // validate dry-run flag value with set of allowed value allowedDryRunValues := []string{"false", "true", "none", "client", "server"} isAllowed := false for _, v := range allowedDryRunValues { - if client.DryRun == v { + if dryRunFlagValue == v { isAllowed = true break } diff --git a/cmd/helm/upgrade.go b/cmd/helm/upgrade.go index 3b2325a69..adbacd1fd 100644 --- a/cmd/helm/upgrade.go +++ b/cmd/helm/upgrade.go @@ -120,11 +120,6 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { instClient.Description = client.Description instClient.DependencyUpdate = client.DependencyUpdate - // validate dry-run flag value is one of the allowed values - if err := validateDryRunFlag(instClient); err != nil { - return err - } - rel, err := runInstall(args, instClient, valueOpts, out) if err != nil { return err @@ -144,6 +139,10 @@ func newUpgradeCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { if err != nil { return err } + // validate dry-run flag value is one of the allowed values + if err := validateDryRunFlag(client.DryRun); err != nil { + return err + } p := getter.All(settings) vals, err := valueOpts.MergeValues(p) diff --git a/pkg/action/action.go b/pkg/action/action.go index c8a1a9d03..f59a31853 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -125,7 +125,7 @@ func (cfg *Configuration) renderResources(ch *chart.Chart, values chartutil.Valu // This enables the ability to render 'lookup' functions. // It may break in interesting and exotic ways because other data (e.g. discovery) // is mocked. - if (dryRun == "server" || dryRun == "none" || dryRun == "false") && cfg.RESTClientGetter != nil { + if (dryRun == "server" || dryRun == "none" || dryRun == "false") && cfg.RESTClientGetter != nil { restConfig, err := cfg.RESTClientGetter.ToRESTConfig() if err != nil { return hs, b, "", err diff --git a/pkg/action/install.go b/pkg/action/install.go index 4eb802f1f..f1c9176fc 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -243,7 +243,7 @@ func (i *Install) RunWithContext(ctx context.Context, chrt *chart.Chart, vals ma } // special case for helm template --is-upgrade - isUpgrade := i.IsUpgrade && (i.DryRun != "none" && i.DryRun != "false") + isUpgrade := i.IsUpgrade && (i.DryRun != "none" && i.DryRun != "false") options := chartutil.ReleaseOptions{ Name: i.ReleaseName, Namespace: i.Namespace, diff --git a/pkg/action/upgrade.go b/pkg/action/upgrade.go index c82704d31..f0e246156 100644 --- a/pkg/action/upgrade.go +++ b/pkg/action/upgrade.go @@ -154,7 +154,7 @@ func (u *Upgrade) RunWithContext(ctx context.Context, name string, chart *chart. return res, err } // Do not update for dry runs - if u.DryRun == "none" || u.DryRun == "false" { + if u.DryRun == "none" || u.DryRun == "false" { u.cfg.Log("updating status for upgraded release for %s", name) if err := u.cfg.Releases.Update(upgradedRelease); err != nil { return res, err