parent
ac25cc5d47
commit
c710e2b01c
|
|
@ -109,14 +109,15 @@ func (st *HelmState) appendWaitFlags(flags []string, release *ReleaseSpec, ops *
|
|||
// appendDryRunFlags appends the necessary flags for a dry run to the given flags slice.
|
||||
// If the opt parameter is not nil and opt.DryRun is not empty, the "--dry-run" flag and the value of opt.DryRun are appended to the flags slice.
|
||||
// The updated flags slice is returned.
|
||||
func (st *HelmState) appendDryRunFlags(flags []string, opt *SyncOpts) []string {
|
||||
if helm.IsVersionAtLeast("3.13.0") {
|
||||
switch {
|
||||
case opt != nil && opt.DryRun != "":
|
||||
flags = append(flags, "--dry-run", opt.DryRun)
|
||||
case opt != nil && opt.DryRun != "":
|
||||
flags = append(flags, "--dry-run", "client")
|
||||
}
|
||||
func (st *HelmState) appendDryRunFlags(flags []string, helm helmexec.Interface, opt *SyncOpts) []string {
|
||||
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")
|
||||
}
|
||||
return flags
|
||||
}
|
||||
|
|
@ -127,6 +128,7 @@ func (st *HelmState) appendCascadeFlags(flags []string, helm helmexec.Interface,
|
|||
if !helm.IsVersionAtLeast("3.12.1") {
|
||||
return flags
|
||||
}
|
||||
|
||||
switch {
|
||||
// postRenderer arg comes from cmd flag.
|
||||
case release.Cascade != nil && *release.Cascade != "":
|
||||
|
|
|
|||
|
|
@ -281,6 +281,8 @@ func TestAppendDryRunFlags(t *testing.T) {
|
|||
type args struct {
|
||||
dryRun string
|
||||
expected []string
|
||||
helm helmexec.Interface
|
||||
flags []string
|
||||
}
|
||||
tests := []struct {
|
||||
name string
|
||||
|
|
@ -289,11 +291,8 @@ func TestAppendDryRunFlags(t *testing.T) {
|
|||
{
|
||||
name: "do dry-run on client",
|
||||
args: args{
|
||||
<<<<<<< Updated upstream
|
||||
dryRun: "client",
|
||||
=======
|
||||
flags: []string{},
|
||||
dry-run: "client",
|
||||
dryRun: "client",
|
||||
helm: testutil.NewVersionHelmExec("3.13.0"),
|
||||
expected: []string{"--dry-run", "client"},
|
||||
},
|
||||
|
|
@ -302,38 +301,34 @@ func TestAppendDryRunFlags(t *testing.T) {
|
|||
name: "empty dry-run means client",
|
||||
args: args{
|
||||
flags: []string{},
|
||||
dry-run: "",
|
||||
dryRun: "",
|
||||
helm: testutil.NewVersionHelmExec("3.13.0"),
|
||||
>>>>>>> Stashed changes
|
||||
expected: []string{"--dry-run", "client"},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "do dry-run on server",
|
||||
args: args{
|
||||
<<<<<<< Updated upstream
|
||||
dryRun: "server",
|
||||
=======
|
||||
flags: []string{},
|
||||
dry-run: "server",
|
||||
dryRun: "server",
|
||||
helm: testutil.NewVersionHelmExec("3.13.0"),
|
||||
>>>>>>> Stashed changes
|
||||
expected: []string{"--dry-run", "server"},
|
||||
},
|
||||
{
|
||||
name: "no version below 3.13.0",
|
||||
args: args{
|
||||
flags: []string{},
|
||||
dry-run: "server",
|
||||
helm: testutil.NewVersionHelmExec("3.12.1"),
|
||||
expected: []string{},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "no version below 3.13.0",
|
||||
args: args{
|
||||
flags: []string{},
|
||||
dryRun: "server",
|
||||
helm: testutil.NewVersionHelmExec("3.12.1"),
|
||||
expected: []string{},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
st := &HelmState{}
|
||||
got := st.appendDryRunFlags([]string{}, &SyncOpts{
|
||||
got := st.appendDryRunFlags([]string{}, tt.args.helm, &SyncOpts{
|
||||
DryRun: tt.args.dryRun,
|
||||
})
|
||||
require.Equalf(t, tt.args.expected, got, "appendDryRunFlags() = %v, want %v", got, tt.args.expected)
|
||||
|
|
|
|||
|
|
@ -2673,7 +2673,7 @@ func (st *HelmState) flagsForUpgrade(helm helmexec.Interface, release *ReleaseSp
|
|||
postRendererArgs = opt.PostRendererArgs
|
||||
}
|
||||
flags = st.appendPostRenderArgsFlags(flags, release, postRendererArgs)
|
||||
flags = st.appendDryRunFlags(flags, opt)
|
||||
flags = st.appendDryRunFlags(flags, helm, opt)
|
||||
|
||||
flags = st.appendExtraSyncFlags(flags, opt)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue