diff --git a/cmd/apply.go b/cmd/apply.go index 6ee8ac3e..1cbb74f7 100644 --- a/cmd/apply.go +++ b/cmd/apply.go @@ -71,6 +71,7 @@ func NewApplyCmd(globalCfg *config.GlobalImpl) *cobra.Command { f.StringVar(&applyOptions.Cascade, "cascade", "", "pass cascade to helm exec, default: background") f.StringArrayVar(&applyOptions.SuppressOutputLineRegex, "suppress-output-line-regex", nil, "a list of regex patterns to suppress output lines from the diff output") f.StringVar(&applyOptions.DryRun, "dry-run", "", "pass dry-run to helm exec") + f.Lookup("dry-run").NoOptDefVal = "client" return cmd } diff --git a/cmd/sync.go b/cmd/sync.go index d042f782..b9df483c 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -49,6 +49,7 @@ func NewSyncCmd(globalCfg *config.GlobalImpl) *cobra.Command { f.StringArrayVar(&syncOptions.PostRendererArgs, "post-renderer-args", nil, `pass --post-renderer-args to "helm template" or "helm upgrade --install"`) f.StringVar(&syncOptions.Cascade, "cascade", "", "pass cascade to helm exec, default: background") f.StringVar(&syncOptions.DryRun, "dry-run", "", "pass dry-run to helm exec") + f.Lookup("dry-run").NoOptDefVal = "client" return cmd } diff --git a/pkg/state/helmx.go b/pkg/state/helmx.go index 9f9ec485..1790cc68 100644 --- a/pkg/state/helmx.go +++ b/pkg/state/helmx.go @@ -113,11 +113,8 @@ func (st *HelmState) appendDryRunFlags(flags []string, helm helmexec.Interface, if !helm.IsVersionAtLeast("3.13.0") { return flags } - switch { - case opt != nil && opt.DryRun != "": - flags = append(flags, "--dry-run", opt.DryRun) - case opt != nil && opt.DryRun == "": - flags = append(flags, "--dry-run", "client") + if opt != nil && opt.DryRun != "" { + flags = append(flags, fmt.Sprintf("--dry-run=%s", opt.DryRun)) } return flags } diff --git a/pkg/state/helmx_test.go b/pkg/state/helmx_test.go index ef27a4d8..d699e3bb 100644 --- a/pkg/state/helmx_test.go +++ b/pkg/state/helmx_test.go @@ -294,7 +294,7 @@ func TestAppendDryRunFlags(t *testing.T) { flags: []string{}, dryRun: "client", helm: testutil.NewVersionHelmExec("3.13.0"), - expected: []string{"--dry-run", "client"}, + expected: []string{"--dry-run=client"}, }, }, { @@ -303,7 +303,7 @@ func TestAppendDryRunFlags(t *testing.T) { flags: []string{}, dryRun: "", helm: testutil.NewVersionHelmExec("3.13.0"), - expected: []string{"--dry-run", "client"}, + expected: []string{}, }, }, { @@ -312,7 +312,7 @@ func TestAppendDryRunFlags(t *testing.T) { flags: []string{}, dryRun: "server", helm: testutil.NewVersionHelmExec("3.13.0"), - expected: []string{"--dry-run", "server"}, + expected: []string{"--dry-run=server"}, }, }, { diff --git a/test/integration/test-cases/happypath/input/happypath.yaml b/test/integration/test-cases/happypath/input/happypath.yaml index 9e475026..86bf5096 100644 --- a/test/integration/test-cases/happypath/input/happypath.yaml +++ b/test/integration/test-cases/happypath/input/happypath.yaml @@ -7,9 +7,6 @@ repositories: - name: incubator url: https://charts.helm.sh/incubator -helmDefaults: - kubeContext: minikube - releases: - name: httpbin diff --git a/test/integration/test-cases/secretssops/input/secretssops.yaml b/test/integration/test-cases/secretssops/input/secretssops.yaml index d52bcbdb..2194c7c5 100644 --- a/test/integration/test-cases/secretssops/input/secretssops.yaml +++ b/test/integration/test-cases/secretssops/input/secretssops.yaml @@ -16,9 +16,6 @@ repositories: - name: incubator url: https://charts.helm.sh/incubator -helmDefaults: - kubeContext: minikube - releases: - name: raw