fix issues

Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
yxxhero 2024-02-10 14:37:40 +08:00
parent c710e2b01c
commit cc3202e9b9
6 changed files with 7 additions and 14 deletions

View File

@ -71,6 +71,7 @@ func NewApplyCmd(globalCfg *config.GlobalImpl) *cobra.Command {
f.StringVar(&applyOptions.Cascade, "cascade", "", "pass cascade to helm exec, default: background") 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.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.StringVar(&applyOptions.DryRun, "dry-run", "", "pass dry-run to helm exec")
f.Lookup("dry-run").NoOptDefVal = "client"
return cmd return cmd
} }

View File

@ -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.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.Cascade, "cascade", "", "pass cascade to helm exec, default: background")
f.StringVar(&syncOptions.DryRun, "dry-run", "", "pass dry-run to helm exec") f.StringVar(&syncOptions.DryRun, "dry-run", "", "pass dry-run to helm exec")
f.Lookup("dry-run").NoOptDefVal = "client"
return cmd return cmd
} }

View File

@ -113,11 +113,8 @@ func (st *HelmState) appendDryRunFlags(flags []string, helm helmexec.Interface,
if !helm.IsVersionAtLeast("3.13.0") { if !helm.IsVersionAtLeast("3.13.0") {
return flags return flags
} }
switch { if opt != nil && opt.DryRun != "" {
case opt != nil && opt.DryRun != "": flags = append(flags, fmt.Sprintf("--dry-run=%s", opt.DryRun))
flags = append(flags, "--dry-run", opt.DryRun)
case opt != nil && opt.DryRun == "":
flags = append(flags, "--dry-run", "client")
} }
return flags return flags
} }

View File

@ -294,7 +294,7 @@ func TestAppendDryRunFlags(t *testing.T) {
flags: []string{}, flags: []string{},
dryRun: "client", dryRun: "client",
helm: testutil.NewVersionHelmExec("3.13.0"), 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{}, flags: []string{},
dryRun: "", dryRun: "",
helm: testutil.NewVersionHelmExec("3.13.0"), helm: testutil.NewVersionHelmExec("3.13.0"),
expected: []string{"--dry-run", "client"}, expected: []string{},
}, },
}, },
{ {
@ -312,7 +312,7 @@ func TestAppendDryRunFlags(t *testing.T) {
flags: []string{}, flags: []string{},
dryRun: "server", dryRun: "server",
helm: testutil.NewVersionHelmExec("3.13.0"), helm: testutil.NewVersionHelmExec("3.13.0"),
expected: []string{"--dry-run", "server"}, expected: []string{"--dry-run=server"},
}, },
}, },
{ {

View File

@ -7,9 +7,6 @@ repositories:
- name: incubator - name: incubator
url: https://charts.helm.sh/incubator url: https://charts.helm.sh/incubator
helmDefaults:
kubeContext: minikube
releases: releases:
- name: httpbin - name: httpbin

View File

@ -16,9 +16,6 @@ repositories:
- name: incubator - name: incubator
url: https://charts.helm.sh/incubator url: https://charts.helm.sh/incubator
helmDefaults:
kubeContext: minikube
releases: releases:
- name: raw - name: raw