Merge pull request #68 from pelotech/ATOMICS

Atomics
This commit is contained in:
Erin Call 2020-01-07 12:34:32 -08:00 committed by GitHub
commit e071d23fef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 22 additions and 11 deletions

View file

@ -38,6 +38,7 @@ Installations are triggered when the `helm_command` setting is "upgrade." They c
| wait | boolean | | Wait until kubernetes resources are in a ready state before marking the installation successful. | | wait | boolean | | Wait until kubernetes resources are in a ready state before marking the installation successful. |
| 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`. |
| 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

@ -43,6 +43,7 @@ type Config struct {
Chart string `` // Chart argument to use in applicable helm commands Chart string `` // Chart argument to use in applicable helm commands
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`
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

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

View file

@ -130,17 +130,18 @@ func (suite *PlanTestSuite) TestExecuteAbortsOnError() {
func (suite *PlanTestSuite) TestUpgrade() { func (suite *PlanTestSuite) TestUpgrade() {
cfg := Config{ cfg := Config{
ChartVersion: "seventeen", ChartVersion: "seventeen",
DryRun: true, DryRun: true,
Wait: true, Wait: true,
Values: "steadfastness,forthrightness", Values: "steadfastness,forthrightness",
StringValues: "tensile_strength,flexibility", StringValues: "tensile_strength,flexibility",
ValuesFiles: []string{"/root/price_inventory.yml"}, ValuesFiles: []string{"/root/price_inventory.yml"},
ReuseValues: true, ReuseValues: true,
Timeout: "go sit in the corner", Timeout: "go sit in the corner",
Chart: "billboard_top_100", Chart: "billboard_top_100",
Release: "post_malone_circles", Release: "post_malone_circles",
Force: true, Force: true,
AtomicUpgrade: true,
} }
steps := upgrade(cfg) steps := upgrade(cfg)
@ -162,6 +163,7 @@ func (suite *PlanTestSuite) TestUpgrade() {
ReuseValues: cfg.ReuseValues, ReuseValues: cfg.ReuseValues,
Timeout: cfg.Timeout, Timeout: cfg.Timeout,
Force: cfg.Force, Force: cfg.Force,
Atomic: true,
} }
suite.Equal(expected, upgrade) suite.Equal(expected, upgrade)

View file

@ -18,6 +18,7 @@ type Upgrade struct {
ReuseValues bool ReuseValues bool
Timeout string Timeout string
Force bool Force bool
Atomic bool
cmd cmd cmd cmd
} }
@ -65,6 +66,9 @@ func (u *Upgrade) Prepare(cfg Config) error {
if u.Force { if u.Force {
args = append(args, "--force") args = append(args, "--force")
} }
if u.Atomic {
args = append(args, "--atomic")
}
if u.Values != "" { if u.Values != "" {
args = append(args, "--set", u.Values) args = append(args, "--set", u.Values)
} }

View file

@ -100,6 +100,7 @@ func (suite *UpgradeTestSuite) TestPrepareWithUpgradeFlags() {
ReuseValues: true, ReuseValues: true,
Timeout: "sit_in_the_corner", Timeout: "sit_in_the_corner",
Force: true, Force: true,
Atomic: true,
} }
cfg := Config{} cfg := Config{}
@ -113,6 +114,7 @@ func (suite *UpgradeTestSuite) TestPrepareWithUpgradeFlags() {
"--reuse-values", "--reuse-values",
"--timeout", "sit_in_the_corner", "--timeout", "sit_in_the_corner",
"--force", "--force",
"--atomic",
"--set", "age=35", "--set", "age=35",
"--set-string", "height=5ft10in", "--set-string", "height=5ft10in",
"--values", "/usr/local/stats", "--values", "/usr/local/stats",