diff --git a/cmd/sync.go b/cmd/sync.go index 7afd8ab6..d042f782 100644 --- a/cmd/sync.go +++ b/cmd/sync.go @@ -48,7 +48,7 @@ func NewSyncCmd(globalCfg *config.GlobalImpl) *cobra.Command { f.StringVar(&syncOptions.PostRenderer, "post-renderer", "", `pass --post-renderer 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.DryRyn, "dry-run", "", "pass dry-run to helm exec") + f.StringVar(&syncOptions.DryRun, "dry-run", "", "pass dry-run to helm exec") return cmd } diff --git a/pkg/config/apply.go b/pkg/config/apply.go index f884f87d..70be7efa 100644 --- a/pkg/config/apply.go +++ b/pkg/config/apply.go @@ -67,7 +67,7 @@ type ApplyOptions struct { // SyncArgs is the list of arguments to pass to helm upgrade. SyncArgs string // DryRun is for helm dry-run flag - DryRyn string + DryRun string } // NewApply creates a new Apply @@ -252,5 +252,5 @@ func (a *ApplyImpl) SyncArgs() string { // DryRun returns dry-run flag func (a *ApplyImpl) DryRun() string { - return a.ApplyOptions.DryRyn + return a.ApplyOptions.DryRun } diff --git a/pkg/config/sync.go b/pkg/config/sync.go index bcd7fd9a..baa1622f 100644 --- a/pkg/config/sync.go +++ b/pkg/config/sync.go @@ -35,7 +35,7 @@ type SyncOptions struct { // SyncArgs is the list of arguments to pass to the helm upgrade command. SyncArgs string // DryRun is for helm dry-run flag - DryRyn string + DryRun string } // NewSyncOptions creates a new Apply @@ -144,5 +144,5 @@ func (t *SyncImpl) SyncArgs() string { // DryRun returns dry-run flag func (t *SyncImpl) DryRun() string { - return t.SyncOptions.DryRyn + return t.SyncOptions.DryRun } diff --git a/pkg/state/helmx_test.go b/pkg/state/helmx_test.go index 31f6d71c..d3c8d8e2 100644 --- a/pkg/state/helmx_test.go +++ b/pkg/state/helmx_test.go @@ -276,3 +276,42 @@ func TestAppendShowOnlyFlags(t *testing.T) { }) } } + +func TestAppendDryRunFlags(t *testing.T) { + type args struct { + flags []string + dry-run string + helm helmexec.Interface + expected []string + } + tests := []struct { + name string + args args + }{ + { + name: "do dry-run on client", + args: args{ + flags: []string{}, + dry-run: "client", + helm: testutil.NewVersionHelmExec("3.12.1"), + expected: []string{"--dry-run", "client"}, + }, + }, + { + name: "do dry-run on server", + args: args{ + flags: []string{}, + dry-run: "server", + helm: testutil.NewVersionHelmExec("3.12.1"), + expected: []string{"--dry-run", "server"}, + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + st := &HelmState{} + got := st.appendDryRunFlags(tt.args.flags, tt.args.helm, tt.args.release, tt.args.dry-run) + require.Equalf(t, tt.args.expected, got, "appendDryRunFlags() = %v, want %v", got, tt.args.expected) + }) + } +}