diff --git a/command/helpers.go b/command/helpers.go index e36de54d5..9e64b974c 100644 --- a/command/helpers.go +++ b/command/helpers.go @@ -229,18 +229,18 @@ READ: return l.ReadCloser.Read(p) } -type Helper struct { +type JobGetter struct { // The fields below can be overwritten for tests testStdin io.Reader } // StructJob returns the Job struct from jobfile. -func (h *Helper) StructJob(jpath string) (*structs.Job, error) { +func (j *JobGetter) StructJob(jpath string) (*structs.Job, error) { var jobfile io.Reader switch jpath { case "-": - if h.testStdin != nil { - jobfile = h.testStdin + if j.testStdin != nil { + jobfile = j.testStdin } else { jobfile = os.Stdin } diff --git a/command/helpers_test.go b/command/helpers_test.go index 8ac1c6548..a6b3c8d99 100644 --- a/command/helpers_test.go +++ b/command/helpers_test.go @@ -213,8 +213,8 @@ job "job1" { t.Fatalf("err: %s", err) } - h := &Helper{} - sj, err := h.StructJob(fh.Name()) + j := &JobGetter{} + sj, err := j.StructJob(fh.Name()) if err != nil { t.Fatalf("err: %s", err) } diff --git a/command/plan.go b/command/plan.go index 1bfe4a726..717ae255c 100644 --- a/command/plan.go +++ b/command/plan.go @@ -25,7 +25,7 @@ potentially invalid.` type PlanCommand struct { Meta - Helper + JobGetter color *colorstring.Colorize } @@ -99,7 +99,7 @@ func (c *PlanCommand) Run(args []string) int { path := args[0] // Get Job struct from Jobfile - job, err := c.Helper.StructJob(args[0]) + job, err := c.JobGetter.StructJob(args[0]) if err != nil { c.Ui.Error(fmt.Sprintf("Error getting job struct: %s", err)) return 1 diff --git a/command/plan_test.go b/command/plan_test.go index c5eda47d1..90dac183e 100644 --- a/command/plan_test.go +++ b/command/plan_test.go @@ -110,8 +110,8 @@ func TestPlanCommand_From_STDIN(t *testing.T) { ui := new(cli.MockUi) cmd := &PlanCommand{ - Meta: Meta{Ui: ui}, - Helper: Helper{testStdin: stdinR}, + Meta: Meta{Ui: ui}, + JobGetter: JobGetter{testStdin: stdinR}, } go func() { diff --git a/command/run.go b/command/run.go index a755a1929..3395eb3d0 100644 --- a/command/run.go +++ b/command/run.go @@ -21,7 +21,7 @@ var ( type RunCommand struct { Meta - Helper + JobGetter } func (c *RunCommand) Help() string { @@ -120,7 +120,7 @@ func (c *RunCommand) Run(args []string) int { } // Get Job struct from Jobfile - job, err := c.Helper.StructJob(args[0]) + job, err := c.JobGetter.StructJob(args[0]) if err != nil { c.Ui.Error(fmt.Sprintf("Error getting job struct: %s", err)) return 1 diff --git a/command/run_test.go b/command/run_test.go index 9d2fab648..b4514efac 100644 --- a/command/run_test.go +++ b/command/run_test.go @@ -156,8 +156,8 @@ func TestRunCommand_From_STDIN(t *testing.T) { ui := new(cli.MockUi) cmd := &RunCommand{ - Meta: Meta{Ui: ui}, - Helper: Helper{testStdin: stdinR}, + Meta: Meta{Ui: ui}, + JobGetter: JobGetter{testStdin: stdinR}, } go func() { diff --git a/command/validate.go b/command/validate.go index 164983374..6557c3ee8 100644 --- a/command/validate.go +++ b/command/validate.go @@ -7,7 +7,7 @@ import ( type ValidateCommand struct { Meta - Helper + JobGetter } func (c *ValidateCommand) Help() string { @@ -43,7 +43,7 @@ func (c *ValidateCommand) Run(args []string) int { } // Get Job struct from Jobfile - job, err := c.Helper.StructJob(args[0]) + job, err := c.JobGetter.StructJob(args[0]) if err != nil { c.Ui.Error(fmt.Sprintf("Error getting job struct: %s", err)) return 1 diff --git a/command/validate_test.go b/command/validate_test.go index 781090b7d..308980274 100644 --- a/command/validate_test.go +++ b/command/validate_test.go @@ -111,8 +111,8 @@ func TestValidateCommand_From_STDIN(t *testing.T) { ui := new(cli.MockUi) cmd := &ValidateCommand{ - Meta: Meta{Ui: ui}, - Helper: Helper{testStdin: stdinR}, + Meta: Meta{Ui: ui}, + JobGetter: JobGetter{testStdin: stdinR}, } go func() {