Skip to content

Commit fb7c54e

Browse files
committed
fix issues
Signed-off-by: yxxhero <[email protected]>
1 parent f4629d4 commit fb7c54e

File tree

6 files changed

+7
-14
lines changed

6 files changed

+7
-14
lines changed

cmd/apply.go

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ func NewApplyCmd(globalCfg *config.GlobalImpl) *cobra.Command {
6969
f.StringArrayVar(&applyOptions.PostRendererArgs, "post-renderer-args", nil, `pass --post-renderer-args to "helm template" or "helm upgrade --install"`)
7070
f.StringVar(&applyOptions.Cascade, "cascade", "", "pass cascade to helm exec, default: background")
7171
f.StringVar(&applyOptions.DryRun, "dry-run", "", "pass dry-run to helm exec")
72+
f.Lookup("dry-run").NoOptDefVal = "client"
7273

7374
return cmd
7475
}

cmd/sync.go

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func NewSyncCmd(globalCfg *config.GlobalImpl) *cobra.Command {
4848
f.StringArrayVar(&syncOptions.PostRendererArgs, "post-renderer-args", nil, `pass --post-renderer-args to "helm template" or "helm upgrade --install"`)
4949
f.StringVar(&syncOptions.Cascade, "cascade", "", "pass cascade to helm exec, default: background")
5050
f.StringVar(&syncOptions.DryRun, "dry-run", "", "pass dry-run to helm exec")
51+
f.Lookup("dry-run").NoOptDefVal = "client"
5152

5253
return cmd
5354
}

pkg/state/helmx.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,8 @@ func (st *HelmState) appendDryRunFlags(flags []string, helm helmexec.Interface,
100100
if !helm.IsVersionAtLeast("3.13.0") {
101101
return flags
102102
}
103-
switch {
104-
case opt != nil && opt.DryRun != "":
105-
flags = append(flags, "--dry-run", opt.DryRun)
106-
case opt != nil && opt.DryRun == "":
107-
flags = append(flags, "--dry-run", "client")
103+
if opt != nil && opt.DryRun != "" {
104+
flags = append(flags, fmt.Sprintf("--dry-run=%s", opt.DryRun))
108105
}
109106
return flags
110107
}

pkg/state/helmx_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ func TestAppendDryRunFlags(t *testing.T) {
215215
flags: []string{},
216216
dryRun: "client",
217217
helm: testutil.NewVersionHelmExec("3.13.0"),
218-
expected: []string{"--dry-run", "client"},
218+
expected: []string{"--dry-run=client"},
219219
},
220220
},
221221
{
@@ -224,7 +224,7 @@ func TestAppendDryRunFlags(t *testing.T) {
224224
flags: []string{},
225225
dryRun: "",
226226
helm: testutil.NewVersionHelmExec("3.13.0"),
227-
expected: []string{"--dry-run", "client"},
227+
expected: []string{},
228228
},
229229
},
230230
{
@@ -233,7 +233,7 @@ func TestAppendDryRunFlags(t *testing.T) {
233233
flags: []string{},
234234
dryRun: "server",
235235
helm: testutil.NewVersionHelmExec("3.13.0"),
236-
expected: []string{"--dry-run", "server"},
236+
expected: []string{"--dry-run=server"},
237237
},
238238
},
239239
{

test/integration/test-cases/happypath/input/happypath.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ repositories:
77
- name: incubator
88
url: https://charts.helm.sh/incubator
99

10-
helmDefaults:
11-
kubeContext: minikube
12-
1310
releases:
1411

1512
- name: httpbin

test/integration/test-cases/secretssops/input/secretssops.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ repositories:
1616
- name: incubator
1717
url: https://charts.helm.sh/incubator
1818

19-
helmDefaults:
20-
kubeContext: minikube
21-
2219
releases:
2320

2421
- name: raw

0 commit comments

Comments
 (0)