CleanupOnFail option for the upgrade Step [#65]

This commit is contained in:
Erin Call 2020-01-07 12:53:55 -08:00
parent e071d23fef
commit 8c6c6fbfa5
No known key found for this signature in database
GPG key ID: 4071FF6C15B8DAD1
2 changed files with 28 additions and 22 deletions

View file

@ -9,16 +9,17 @@ type Upgrade struct {
Chart string Chart string
Release string Release string
ChartVersion string ChartVersion string
DryRun bool DryRun bool
Wait bool Wait bool
Values string Values string
StringValues string StringValues string
ValuesFiles []string ValuesFiles []string
ReuseValues bool ReuseValues bool
Timeout string Timeout string
Force bool Force bool
Atomic bool Atomic bool
CleanupOnFail bool
cmd cmd cmd cmd
} }
@ -69,6 +70,9 @@ func (u *Upgrade) Prepare(cfg Config) error {
if u.Atomic { if u.Atomic {
args = append(args, "--atomic") args = append(args, "--atomic")
} }
if u.CleanupOnFail {
args = append(args, "--cleanup-on-fail")
}
if u.Values != "" { if u.Values != "" {
args = append(args, "--set", u.Values) args = append(args, "--set", u.Values)
} }

View file

@ -89,18 +89,19 @@ func (suite *UpgradeTestSuite) TestPrepareWithUpgradeFlags() {
defer suite.ctrl.Finish() defer suite.ctrl.Finish()
u := Upgrade{ u := Upgrade{
Chart: "hot_ac", Chart: "hot_ac",
Release: "maroon_5_memories", Release: "maroon_5_memories",
ChartVersion: "radio_edit", ChartVersion: "radio_edit",
DryRun: true, DryRun: true,
Wait: true, Wait: true,
Values: "age=35", Values: "age=35",
StringValues: "height=5ft10in", StringValues: "height=5ft10in",
ValuesFiles: []string{"/usr/local/stats", "/usr/local/grades"}, ValuesFiles: []string{"/usr/local/stats", "/usr/local/grades"},
ReuseValues: true, ReuseValues: true,
Timeout: "sit_in_the_corner", Timeout: "sit_in_the_corner",
Force: true, Force: true,
Atomic: true, Atomic: true,
CleanupOnFail: true,
} }
cfg := Config{} cfg := Config{}
@ -115,6 +116,7 @@ func (suite *UpgradeTestSuite) TestPrepareWithUpgradeFlags() {
"--timeout", "sit_in_the_corner", "--timeout", "sit_in_the_corner",
"--force", "--force",
"--atomic", "--atomic",
"--cleanup-on-fail",
"--set", "age=35", "--set", "age=35",
"--set-string", "height=5ft10in", "--set-string", "height=5ft10in",
"--values", "/usr/local/stats", "--values", "/usr/local/stats",