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.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
}

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.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
}

View File

@ -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
}

View File

@ -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"},
},
},
{

View File

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

View File

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