Merge pull request #69 from pelotech/cleanup-on-fail

Pass --cleanup-on-fail when so instructed
This commit is contained in:
Erin Call 2020-01-07 13:18:31 -08:00 committed by GitHub
commit 7cfe20db1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 57 additions and 46 deletions

View file

@ -39,6 +39,7 @@ Installations are triggered when the `helm_command` setting is "upgrade." They c
| timeout | duration | | Timeout for any *individual* Kubernetes operation. The installation's full runtime may exceed this duration. | | timeout | duration | | Timeout for any *individual* Kubernetes operation. The installation's full runtime may exceed this duration. |
| force | boolean | | Pass `--force` to `helm upgrade`. | | force | boolean | | Pass `--force` to `helm upgrade`. |
| atomic_upgrade | boolean | | Pass `--atomic` to `helm upgrade`. | | atomic_upgrade | boolean | | Pass `--atomic` to `helm upgrade`. |
| cleanup_failed_upgrade | boolean | | Pass `--cleanup-on-fail` to `helm upgrade`. |
| values | list\<string\> | | Chart values to use as the `--set` argument to `helm upgrade`. | | values | list\<string\> | | Chart values to use as the `--set` argument to `helm upgrade`. |
| string_values | list\<string\> | | Chart values to use as the `--set-string` argument to `helm upgrade`. | | string_values | list\<string\> | | Chart values to use as the `--set-string` argument to `helm upgrade`. |
| values_files | list\<string\> | | Values to use as `--values` arguments to `helm upgrade`. | | values_files | list\<string\> | | Values to use as `--values` arguments to `helm upgrade`. |

View file

@ -44,6 +44,7 @@ type Config struct {
Release string `` // Release argument to use in applicable helm commands Release string `` // Release argument to use in applicable helm commands
Force bool `` // Pass --force to applicable helm commands Force bool `` // Pass --force to applicable helm commands
AtomicUpgrade bool `split_words:"true"` // Pass --atomic to `helm upgrade` AtomicUpgrade bool `split_words:"true"` // Pass --atomic to `helm upgrade`
CleanupOnFail bool `envconfig:"CLEANUP_FAILED_UPGRADE"` // Pass --cleanup-on-fail to `helm upgrade`
LintStrictly bool `split_words:"true"` // Pass --strict to `helm lint` LintStrictly bool `split_words:"true"` // Pass --strict to `helm lint`
Stdout io.Writer `ignored:"true"` Stdout io.Writer `ignored:"true"`

View file

@ -110,6 +110,7 @@ var upgrade = func(cfg Config) []Step {
Timeout: cfg.Timeout, Timeout: cfg.Timeout,
Force: cfg.Force, Force: cfg.Force,
Atomic: cfg.AtomicUpgrade, Atomic: cfg.AtomicUpgrade,
CleanupOnFail: cfg.CleanupOnFail,
}) })
return steps return steps

View file

@ -142,6 +142,7 @@ func (suite *PlanTestSuite) TestUpgrade() {
Release: "post_malone_circles", Release: "post_malone_circles",
Force: true, Force: true,
AtomicUpgrade: true, AtomicUpgrade: true,
CleanupOnFail: true,
} }
steps := upgrade(cfg) steps := upgrade(cfg)
@ -164,6 +165,7 @@ func (suite *PlanTestSuite) TestUpgrade() {
Timeout: cfg.Timeout, Timeout: cfg.Timeout,
Force: cfg.Force, Force: cfg.Force,
Atomic: true, Atomic: true,
CleanupOnFail: true,
} }
suite.Equal(expected, upgrade) suite.Equal(expected, upgrade)

View file

@ -19,6 +19,7 @@ type Upgrade struct {
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

@ -101,6 +101,7 @@ func (suite *UpgradeTestSuite) TestPrepareWithUpgradeFlags() {
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",