Put HelmCommand in Help, not run.Config [#15]

This commit is contained in:
Erin Call 2019-12-26 12:23:56 -08:00
parent b1899dee56
commit 167b53691b
No known key found for this signature in database
GPG key ID: 4071FF6C15B8DAD1
5 changed files with 11 additions and 12 deletions

View file

@ -29,7 +29,6 @@ func NewPlan(cfg Config) (*Plan, error) {
p := Plan{ p := Plan{
cfg: cfg, cfg: cfg,
runCfg: run.Config{ runCfg: run.Config{
HelmCommand: string(cfg.Command),
Debug: cfg.Debug, Debug: cfg.Debug,
Values: cfg.Values, Values: cfg.Values,
StringValues: cfg.StringValues, StringValues: cfg.StringValues,
@ -132,7 +131,9 @@ var lint = func(cfg Config) []Step {
} }
var help = func(cfg Config) []Step { var help = func(cfg Config) []Step {
help := &run.Help{} help := &run.Help{
HelmCommand: cfg.Command,
}
return []Step{help} return []Step{help}
} }

View file

@ -43,7 +43,6 @@ func (suite *PlanTestSuite) TestNewPlan() {
} }
runCfg := run.Config{ runCfg := run.Config{
HelmCommand: "help",
Debug: false, Debug: false,
Values: "steadfastness,forthrightness", Values: "steadfastness,forthrightness",
StringValues: "tensile_strength,flexibility", StringValues: "tensile_strength,flexibility",

View file

@ -6,7 +6,6 @@ import (
// Config contains configuration applicable to all helm commands // Config contains configuration applicable to all helm commands
type Config struct { type Config struct {
HelmCommand string
Debug bool Debug bool
Values string Values string
StringValues string StringValues string

View file

@ -6,7 +6,8 @@ import (
// Help is a step in a helm Plan that calls `helm help`. // Help is a step in a helm Plan that calls `helm help`.
type Help struct { type Help struct {
cmd cmd HelmCommand string
cmd cmd
} }
// Execute executes the `helm help` command. // Execute executes the `helm help` command.
@ -15,10 +16,10 @@ func (h *Help) Execute(cfg Config) error {
return fmt.Errorf("while running '%s': %w", h.cmd.String(), err) return fmt.Errorf("while running '%s': %w", h.cmd.String(), err)
} }
if cfg.HelmCommand == "help" { if h.HelmCommand == "help" {
return nil return nil
} }
return fmt.Errorf("unknown command '%s'", cfg.HelmCommand) return fmt.Errorf("unknown command '%s'", h.HelmCommand)
} }
// Prepare gets the Help ready to execute. // Prepare gets the Help ready to execute.

View file

@ -63,15 +63,14 @@ func (suite *HelpTestSuite) TestExecute() {
Run(). Run().
Times(2) Times(2)
cfg := Config{ cfg := Config{}
HelmCommand: "help",
}
help := Help{ help := Help{
cmd: mCmd, HelmCommand: "help",
cmd: mCmd,
} }
suite.NoError(help.Execute(cfg)) suite.NoError(help.Execute(cfg))
cfg.HelmCommand = "get down on friday" help.HelmCommand = "get down on friday"
suite.EqualError(help.Execute(cfg), "unknown command 'get down on friday'") suite.EqualError(help.Execute(cfg), "unknown command 'get down on friday'")
} }