Restrict version of helm, and default dryRun. (#1265)
Signed-off-by: yxxhero <aiopsclub@163.com>
This commit is contained in:
parent
b5095c04a4
commit
ac25cc5d47
|
|
@ -110,8 +110,13 @@ func (st *HelmState) appendWaitFlags(flags []string, release *ReleaseSpec, ops *
|
|||
// 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 opt != nil && opt.DryRun != "" {
|
||||
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")
|
||||
}
|
||||
}
|
||||
return flags
|
||||
}
|
||||
|
|
|
|||
|
|
@ -289,16 +289,45 @@ func TestAppendDryRunFlags(t *testing.T) {
|
|||
{
|
||||
name: "do dry-run on client",
|
||||
args: args{
|
||||
<<<<<<< Updated upstream
|
||||
dryRun: "client",
|
||||
=======
|
||||
flags: []string{},
|
||||
dry-run: "client",
|
||||
helm: testutil.NewVersionHelmExec("3.13.0"),
|
||||
expected: []string{"--dry-run", "client"},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "empty dry-run means client",
|
||||
args: args{
|
||||
flags: []string{},
|
||||
dry-run: "",
|
||||
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",
|
||||
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{},
|
||||
},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
|
|
|||
Loading…
Reference in New Issue