Merge pull request #62 from pelotech/values-arent-global
Put step-specific config in those steps
This commit is contained in:
commit
eaac6dd643
|
@ -29,13 +29,10 @@ func NewPlan(cfg Config) (*Plan, error) {
|
|||
p := Plan{
|
||||
cfg: cfg,
|
||||
runCfg: run.Config{
|
||||
Debug: cfg.Debug,
|
||||
Values: cfg.Values,
|
||||
StringValues: cfg.StringValues,
|
||||
ValuesFiles: cfg.ValuesFiles,
|
||||
Namespace: cfg.Namespace,
|
||||
Stdout: cfg.Stdout,
|
||||
Stderr: cfg.Stderr,
|
||||
Debug: cfg.Debug,
|
||||
Namespace: cfg.Namespace,
|
||||
Stdout: cfg.Stdout,
|
||||
Stderr: cfg.Stderr,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -106,6 +103,9 @@ var upgrade = func(cfg Config) []Step {
|
|||
ChartVersion: cfg.ChartVersion,
|
||||
DryRun: cfg.DryRun,
|
||||
Wait: cfg.Wait,
|
||||
Values: cfg.Values,
|
||||
StringValues: cfg.StringValues,
|
||||
ValuesFiles: cfg.ValuesFiles,
|
||||
ReuseValues: cfg.ReuseValues,
|
||||
Timeout: cfg.Timeout,
|
||||
Force: cfg.Force,
|
||||
|
@ -133,8 +133,11 @@ var lint = func(cfg Config) []Step {
|
|||
steps = append(steps, depUpdate(cfg)...)
|
||||
}
|
||||
steps = append(steps, &run.Lint{
|
||||
Chart: cfg.Chart,
|
||||
Strict: cfg.LintStrictly,
|
||||
Chart: cfg.Chart,
|
||||
Values: cfg.Values,
|
||||
StringValues: cfg.StringValues,
|
||||
ValuesFiles: cfg.ValuesFiles,
|
||||
Strict: cfg.LintStrictly,
|
||||
})
|
||||
|
||||
return steps
|
||||
|
|
|
@ -33,24 +33,18 @@ func (suite *PlanTestSuite) TestNewPlan() {
|
|||
stdout := strings.Builder{}
|
||||
stderr := strings.Builder{}
|
||||
cfg := Config{
|
||||
Command: "help",
|
||||
Debug: false,
|
||||
Values: "steadfastness,forthrightness",
|
||||
StringValues: "tensile_strength,flexibility",
|
||||
ValuesFiles: []string{"/root/price_inventory.yml"},
|
||||
Namespace: "outer",
|
||||
Stdout: &stdout,
|
||||
Stderr: &stderr,
|
||||
Command: "help",
|
||||
Debug: false,
|
||||
Namespace: "outer",
|
||||
Stdout: &stdout,
|
||||
Stderr: &stderr,
|
||||
}
|
||||
|
||||
runCfg := run.Config{
|
||||
Debug: false,
|
||||
Values: "steadfastness,forthrightness",
|
||||
StringValues: "tensile_strength,flexibility",
|
||||
ValuesFiles: []string{"/root/price_inventory.yml"},
|
||||
Namespace: "outer",
|
||||
Stdout: &stdout,
|
||||
Stderr: &stderr,
|
||||
Debug: false,
|
||||
Namespace: "outer",
|
||||
Stdout: &stdout,
|
||||
Stderr: &stderr,
|
||||
}
|
||||
|
||||
stepOne.EXPECT().
|
||||
|
@ -139,6 +133,9 @@ func (suite *PlanTestSuite) TestUpgrade() {
|
|||
ChartVersion: "seventeen",
|
||||
DryRun: true,
|
||||
Wait: true,
|
||||
Values: "steadfastness,forthrightness",
|
||||
StringValues: "tensile_strength,flexibility",
|
||||
ValuesFiles: []string{"/root/price_inventory.yml"},
|
||||
ReuseValues: true,
|
||||
Timeout: "go sit in the corner",
|
||||
Chart: "billboard_top_100",
|
||||
|
@ -159,6 +156,9 @@ func (suite *PlanTestSuite) TestUpgrade() {
|
|||
ChartVersion: cfg.ChartVersion,
|
||||
DryRun: true,
|
||||
Wait: cfg.Wait,
|
||||
Values: "steadfastness,forthrightness",
|
||||
StringValues: "tensile_strength,flexibility",
|
||||
ValuesFiles: []string{"/root/price_inventory.yml"},
|
||||
ReuseValues: cfg.ReuseValues,
|
||||
Timeout: cfg.Timeout,
|
||||
Force: cfg.Force,
|
||||
|
@ -300,6 +300,9 @@ func (suite *PlanTestSuite) TestAddRepos() {
|
|||
func (suite *PlanTestSuite) TestLint() {
|
||||
cfg := Config{
|
||||
Chart: "./flow",
|
||||
Values: "steadfastness,forthrightness",
|
||||
StringValues: "tensile_strength,flexibility",
|
||||
ValuesFiles: []string{"/root/price_inventory.yml"},
|
||||
LintStrictly: true,
|
||||
}
|
||||
|
||||
|
@ -307,8 +310,11 @@ func (suite *PlanTestSuite) TestLint() {
|
|||
suite.Equal(1, len(steps))
|
||||
|
||||
want := &run.Lint{
|
||||
Chart: "./flow",
|
||||
Strict: true,
|
||||
Chart: "./flow",
|
||||
Values: "steadfastness,forthrightness",
|
||||
StringValues: "tensile_strength,flexibility",
|
||||
ValuesFiles: []string{"/root/price_inventory.yml"},
|
||||
Strict: true,
|
||||
}
|
||||
suite.Equal(want, steps[0])
|
||||
}
|
||||
|
|
|
@ -6,11 +6,8 @@ import (
|
|||
|
||||
// Config contains configuration applicable to all helm commands
|
||||
type Config struct {
|
||||
Debug bool
|
||||
Values string
|
||||
StringValues string
|
||||
ValuesFiles []string
|
||||
Namespace string
|
||||
Stdout io.Writer
|
||||
Stderr io.Writer
|
||||
Debug bool
|
||||
Namespace string
|
||||
Stdout io.Writer
|
||||
Stderr io.Writer
|
||||
}
|
||||
|
|
|
@ -6,9 +6,12 @@ import (
|
|||
|
||||
// Lint is an execution step that calls `helm lint` when executed.
|
||||
type Lint struct {
|
||||
Chart string
|
||||
Strict bool
|
||||
cmd cmd
|
||||
Chart string
|
||||
Values string
|
||||
StringValues string
|
||||
ValuesFiles []string
|
||||
Strict bool
|
||||
cmd cmd
|
||||
}
|
||||
|
||||
// Execute executes the `helm lint` command.
|
||||
|
@ -33,13 +36,13 @@ func (l *Lint) Prepare(cfg Config) error {
|
|||
|
||||
args = append(args, "lint")
|
||||
|
||||
if cfg.Values != "" {
|
||||
args = append(args, "--set", cfg.Values)
|
||||
if l.Values != "" {
|
||||
args = append(args, "--set", l.Values)
|
||||
}
|
||||
if cfg.StringValues != "" {
|
||||
args = append(args, "--set-string", cfg.StringValues)
|
||||
if l.StringValues != "" {
|
||||
args = append(args, "--set-string", l.StringValues)
|
||||
}
|
||||
for _, vFile := range cfg.ValuesFiles {
|
||||
for _, vFile := range l.ValuesFiles {
|
||||
args = append(args, "--values", vFile)
|
||||
}
|
||||
if l.Strict {
|
||||
|
|
|
@ -80,15 +80,14 @@ func (suite *LintTestSuite) TestPrepareRequiresChart() {
|
|||
func (suite *LintTestSuite) TestPrepareWithLintFlags() {
|
||||
defer suite.ctrl.Finish()
|
||||
|
||||
cfg := Config{
|
||||
cfg := Config{}
|
||||
|
||||
l := Lint{
|
||||
Chart: "./uk/top_40",
|
||||
Values: "width=5",
|
||||
StringValues: "version=2.0",
|
||||
ValuesFiles: []string{"/usr/local/underrides", "/usr/local/overrides"},
|
||||
}
|
||||
|
||||
l := Lint{
|
||||
Chart: "./uk/top_40",
|
||||
Strict: true,
|
||||
Strict: true,
|
||||
}
|
||||
|
||||
command = func(path string, args ...string) cmd {
|
||||
|
|
|
@ -12,6 +12,9 @@ type Upgrade struct {
|
|||
ChartVersion string
|
||||
DryRun bool
|
||||
Wait bool
|
||||
Values string
|
||||
StringValues string
|
||||
ValuesFiles []string
|
||||
ReuseValues bool
|
||||
Timeout string
|
||||
Force bool
|
||||
|
@ -62,13 +65,13 @@ func (u *Upgrade) Prepare(cfg Config) error {
|
|||
if u.Force {
|
||||
args = append(args, "--force")
|
||||
}
|
||||
if cfg.Values != "" {
|
||||
args = append(args, "--set", cfg.Values)
|
||||
if u.Values != "" {
|
||||
args = append(args, "--set", u.Values)
|
||||
}
|
||||
if cfg.StringValues != "" {
|
||||
args = append(args, "--set-string", cfg.StringValues)
|
||||
if u.StringValues != "" {
|
||||
args = append(args, "--set-string", u.StringValues)
|
||||
}
|
||||
for _, vFile := range cfg.ValuesFiles {
|
||||
for _, vFile := range u.ValuesFiles {
|
||||
args = append(args, "--values", vFile)
|
||||
}
|
||||
|
||||
|
|
|
@ -91,20 +91,19 @@ func (suite *UpgradeTestSuite) TestPrepareWithUpgradeFlags() {
|
|||
u := Upgrade{
|
||||
Chart: "hot_ac",
|
||||
Release: "maroon_5_memories",
|
||||
ChartVersion: "radio_edit", //-version
|
||||
DryRun: true, //-run
|
||||
Wait: true, //-wait
|
||||
ReuseValues: true, //-values
|
||||
Timeout: "sit_in_the_corner", //-timeout
|
||||
Force: true, //-force
|
||||
}
|
||||
|
||||
cfg := Config{
|
||||
ChartVersion: "radio_edit",
|
||||
DryRun: true,
|
||||
Wait: true,
|
||||
Values: "age=35",
|
||||
StringValues: "height=5ft10in",
|
||||
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 {
|
||||
suite.Equal(helmBin, path)
|
||||
suite.Equal([]string{"upgrade", "--install",
|
||||
|
|
Loading…
Reference in a new issue