Merge pull request #62 from pelotech/values-arent-global

Put step-specific config in those steps
This commit is contained in:
Joachim Hill-Grannec 2020-01-02 15:32:05 -05:00 committed by GitHub
commit eaac6dd643
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 71 additions and 61 deletions

View file

@ -30,9 +30,6 @@ func NewPlan(cfg Config) (*Plan, error) {
cfg: cfg, cfg: cfg,
runCfg: run.Config{ runCfg: run.Config{
Debug: cfg.Debug, Debug: cfg.Debug,
Values: cfg.Values,
StringValues: cfg.StringValues,
ValuesFiles: cfg.ValuesFiles,
Namespace: cfg.Namespace, Namespace: cfg.Namespace,
Stdout: cfg.Stdout, Stdout: cfg.Stdout,
Stderr: cfg.Stderr, Stderr: cfg.Stderr,
@ -106,6 +103,9 @@ var upgrade = func(cfg Config) []Step {
ChartVersion: cfg.ChartVersion, ChartVersion: cfg.ChartVersion,
DryRun: cfg.DryRun, DryRun: cfg.DryRun,
Wait: cfg.Wait, Wait: cfg.Wait,
Values: cfg.Values,
StringValues: cfg.StringValues,
ValuesFiles: cfg.ValuesFiles,
ReuseValues: cfg.ReuseValues, ReuseValues: cfg.ReuseValues,
Timeout: cfg.Timeout, Timeout: cfg.Timeout,
Force: cfg.Force, Force: cfg.Force,
@ -134,6 +134,9 @@ var lint = func(cfg Config) []Step {
} }
steps = append(steps, &run.Lint{ steps = append(steps, &run.Lint{
Chart: cfg.Chart, Chart: cfg.Chart,
Values: cfg.Values,
StringValues: cfg.StringValues,
ValuesFiles: cfg.ValuesFiles,
Strict: cfg.LintStrictly, Strict: cfg.LintStrictly,
}) })

View file

@ -35,9 +35,6 @@ func (suite *PlanTestSuite) TestNewPlan() {
cfg := Config{ cfg := Config{
Command: "help", Command: "help",
Debug: false, Debug: false,
Values: "steadfastness,forthrightness",
StringValues: "tensile_strength,flexibility",
ValuesFiles: []string{"/root/price_inventory.yml"},
Namespace: "outer", Namespace: "outer",
Stdout: &stdout, Stdout: &stdout,
Stderr: &stderr, Stderr: &stderr,
@ -45,9 +42,6 @@ func (suite *PlanTestSuite) TestNewPlan() {
runCfg := run.Config{ runCfg := run.Config{
Debug: false, Debug: false,
Values: "steadfastness,forthrightness",
StringValues: "tensile_strength,flexibility",
ValuesFiles: []string{"/root/price_inventory.yml"},
Namespace: "outer", Namespace: "outer",
Stdout: &stdout, Stdout: &stdout,
Stderr: &stderr, Stderr: &stderr,
@ -139,6 +133,9 @@ func (suite *PlanTestSuite) TestUpgrade() {
ChartVersion: "seventeen", ChartVersion: "seventeen",
DryRun: true, DryRun: true,
Wait: true, Wait: true,
Values: "steadfastness,forthrightness",
StringValues: "tensile_strength,flexibility",
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",
@ -159,6 +156,9 @@ func (suite *PlanTestSuite) TestUpgrade() {
ChartVersion: cfg.ChartVersion, ChartVersion: cfg.ChartVersion,
DryRun: true, DryRun: true,
Wait: cfg.Wait, Wait: cfg.Wait,
Values: "steadfastness,forthrightness",
StringValues: "tensile_strength,flexibility",
ValuesFiles: []string{"/root/price_inventory.yml"},
ReuseValues: cfg.ReuseValues, ReuseValues: cfg.ReuseValues,
Timeout: cfg.Timeout, Timeout: cfg.Timeout,
Force: cfg.Force, Force: cfg.Force,
@ -300,6 +300,9 @@ func (suite *PlanTestSuite) TestAddRepos() {
func (suite *PlanTestSuite) TestLint() { func (suite *PlanTestSuite) TestLint() {
cfg := Config{ cfg := Config{
Chart: "./flow", Chart: "./flow",
Values: "steadfastness,forthrightness",
StringValues: "tensile_strength,flexibility",
ValuesFiles: []string{"/root/price_inventory.yml"},
LintStrictly: true, LintStrictly: true,
} }
@ -308,6 +311,9 @@ func (suite *PlanTestSuite) TestLint() {
want := &run.Lint{ want := &run.Lint{
Chart: "./flow", Chart: "./flow",
Values: "steadfastness,forthrightness",
StringValues: "tensile_strength,flexibility",
ValuesFiles: []string{"/root/price_inventory.yml"},
Strict: true, Strict: true,
} }
suite.Equal(want, steps[0]) suite.Equal(want, steps[0])

View file

@ -7,9 +7,6 @@ import (
// Config contains configuration applicable to all helm commands // Config contains configuration applicable to all helm commands
type Config struct { type Config struct {
Debug bool Debug bool
Values string
StringValues string
ValuesFiles []string
Namespace string Namespace string
Stdout io.Writer Stdout io.Writer
Stderr io.Writer Stderr io.Writer

View file

@ -7,6 +7,9 @@ import (
// Lint is an execution step that calls `helm lint` when executed. // Lint is an execution step that calls `helm lint` when executed.
type Lint struct { type Lint struct {
Chart string Chart string
Values string
StringValues string
ValuesFiles []string
Strict bool Strict bool
cmd cmd cmd cmd
} }
@ -33,13 +36,13 @@ func (l *Lint) Prepare(cfg Config) error {
args = append(args, "lint") args = append(args, "lint")
if cfg.Values != "" { if l.Values != "" {
args = append(args, "--set", cfg.Values) args = append(args, "--set", l.Values)
} }
if cfg.StringValues != "" { if l.StringValues != "" {
args = append(args, "--set-string", cfg.StringValues) args = append(args, "--set-string", l.StringValues)
} }
for _, vFile := range cfg.ValuesFiles { for _, vFile := range l.ValuesFiles {
args = append(args, "--values", vFile) args = append(args, "--values", vFile)
} }
if l.Strict { if l.Strict {

View file

@ -80,14 +80,13 @@ func (suite *LintTestSuite) TestPrepareRequiresChart() {
func (suite *LintTestSuite) TestPrepareWithLintFlags() { func (suite *LintTestSuite) TestPrepareWithLintFlags() {
defer suite.ctrl.Finish() defer suite.ctrl.Finish()
cfg := Config{ cfg := Config{}
Values: "width=5",
StringValues: "version=2.0",
ValuesFiles: []string{"/usr/local/underrides", "/usr/local/overrides"},
}
l := Lint{ l := Lint{
Chart: "./uk/top_40", Chart: "./uk/top_40",
Values: "width=5",
StringValues: "version=2.0",
ValuesFiles: []string{"/usr/local/underrides", "/usr/local/overrides"},
Strict: true, Strict: true,
} }

View file

@ -12,6 +12,9 @@ type Upgrade struct {
ChartVersion string ChartVersion string
DryRun bool DryRun bool
Wait bool Wait bool
Values string
StringValues string
ValuesFiles []string
ReuseValues bool ReuseValues bool
Timeout string Timeout string
Force bool Force bool
@ -62,13 +65,13 @@ func (u *Upgrade) Prepare(cfg Config) error {
if u.Force { if u.Force {
args = append(args, "--force") args = append(args, "--force")
} }
if cfg.Values != "" { if u.Values != "" {
args = append(args, "--set", cfg.Values) args = append(args, "--set", u.Values)
} }
if cfg.StringValues != "" { if u.StringValues != "" {
args = append(args, "--set-string", cfg.StringValues) args = append(args, "--set-string", u.StringValues)
} }
for _, vFile := range cfg.ValuesFiles { for _, vFile := range u.ValuesFiles {
args = append(args, "--values", vFile) args = append(args, "--values", vFile)
} }

View file

@ -91,20 +91,19 @@ func (suite *UpgradeTestSuite) TestPrepareWithUpgradeFlags() {
u := Upgrade{ u := Upgrade{
Chart: "hot_ac", Chart: "hot_ac",
Release: "maroon_5_memories", Release: "maroon_5_memories",
ChartVersion: "radio_edit", //-version ChartVersion: "radio_edit",
DryRun: true, //-run DryRun: true,
Wait: true, //-wait Wait: true,
ReuseValues: true, //-values
Timeout: "sit_in_the_corner", //-timeout
Force: true, //-force
}
cfg := Config{
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,
Timeout: "sit_in_the_corner",
Force: true,
} }
cfg := Config{}
command = func(path string, args ...string) cmd { command = func(path string, args ...string) cmd {
suite.Equal(helmBin, path) suite.Equal(helmBin, path)
suite.Equal([]string{"upgrade", "--install", suite.Equal([]string{"upgrade", "--install",