From 167b53691b9eed6f1446c643fe2217aa0f0617f5 Mon Sep 17 00:00:00 2001 From: Erin Call Date: Thu, 26 Dec 2019 12:23:56 -0800 Subject: [PATCH] Put HelmCommand in Help, not run.Config [#15] --- internal/helm/plan.go | 5 +++-- internal/helm/plan_test.go | 1 - internal/run/config.go | 1 - internal/run/help.go | 7 ++++--- internal/run/help_test.go | 9 ++++----- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/internal/helm/plan.go b/internal/helm/plan.go index 72fd48a..a82ffea 100644 --- a/internal/helm/plan.go +++ b/internal/helm/plan.go @@ -29,7 +29,6 @@ func NewPlan(cfg Config) (*Plan, error) { p := Plan{ cfg: cfg, runCfg: run.Config{ - HelmCommand: string(cfg.Command), Debug: cfg.Debug, Values: cfg.Values, StringValues: cfg.StringValues, @@ -132,7 +131,9 @@ var lint = func(cfg Config) []Step { } var help = func(cfg Config) []Step { - help := &run.Help{} + help := &run.Help{ + HelmCommand: cfg.Command, + } return []Step{help} } diff --git a/internal/helm/plan_test.go b/internal/helm/plan_test.go index fc70ec9..ce5311a 100644 --- a/internal/helm/plan_test.go +++ b/internal/helm/plan_test.go @@ -43,7 +43,6 @@ func (suite *PlanTestSuite) TestNewPlan() { } runCfg := run.Config{ - HelmCommand: "help", Debug: false, Values: "steadfastness,forthrightness", StringValues: "tensile_strength,flexibility", diff --git a/internal/run/config.go b/internal/run/config.go index 25fcd6f..4f9b99a 100644 --- a/internal/run/config.go +++ b/internal/run/config.go @@ -6,7 +6,6 @@ import ( // Config contains configuration applicable to all helm commands type Config struct { - HelmCommand string Debug bool Values string StringValues string diff --git a/internal/run/help.go b/internal/run/help.go index a4a116e..f2d6c59 100644 --- a/internal/run/help.go +++ b/internal/run/help.go @@ -6,7 +6,8 @@ import ( // Help is a step in a helm Plan that calls `helm help`. type Help struct { - cmd cmd + HelmCommand string + cmd cmd } // 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) } - if cfg.HelmCommand == "help" { + if h.HelmCommand == "help" { 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. diff --git a/internal/run/help_test.go b/internal/run/help_test.go index ecca2bb..19c49d2 100644 --- a/internal/run/help_test.go +++ b/internal/run/help_test.go @@ -63,15 +63,14 @@ func (suite *HelpTestSuite) TestExecute() { Run(). Times(2) - cfg := Config{ - HelmCommand: "help", - } + cfg := Config{} help := Help{ - cmd: mCmd, + HelmCommand: "help", + cmd: mCmd, } 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'") }