From ffc55d431b2cd107636cf51b55387e658676ba86 Mon Sep 17 00:00:00 2001 From: Daniel Menet Date: Sun, 5 Jan 2020 00:22:03 +0100 Subject: [PATCH] staticcheck: fixed --- cli.go | 2 +- plan.go | 4 +--- workspace.go | 14 +++++++------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/cli.go b/cli.go index 1ad7079..749c1a7 100644 --- a/cli.go +++ b/cli.go @@ -96,7 +96,7 @@ func NewApp() *App { func (a App) debug(out string) { if a.cfg.rootDebug { - fmt.Fprintf(os.Stderr, out) + fmt.Fprint(os.Stderr, out) } } diff --git a/plan.go b/plan.go index 6e74fee..dce0c60 100644 --- a/plan.go +++ b/plan.go @@ -80,9 +80,7 @@ func BuildExecutionPlan(workspaces []*Workspace, roots []string, debug func(stri // get a list of all workspaces that already have been planned planned := []*Workspace{} for _, i := range plan { - for _, j := range i { - planned = append(planned, j) - } + planned = append(planned, i...) } // get a list of uniq unplanned workspaces diff --git a/workspace.go b/workspace.go index 28888fc..4625313 100644 --- a/workspace.go +++ b/workspace.go @@ -253,7 +253,7 @@ func (ws Workspace) getRemoteState() (RemoteState, error) { for filename, file := range ws.Files { terraformMatches := refs["terraform"].FindAll(file.Raw, -1) if len(terraformMatches) > 1 { - return rs, fmt.Errorf("Too many remote state definitions found in %s", filename) + return rs, fmt.Errorf("too many remote state definitions found in %s", filename) } else if len(terraformMatches) < 1 { continue } @@ -368,9 +368,9 @@ func (ws Workspace) getManualDependencies(workspaces map[string]*Workspace) ([]R submaches := re.FindAllStringSubmatch(string(m), -1) for _, sm := range submaches { match := sm[0] - seg := strings.SplitN(strings.Trim(match, "{{}}"), ".", 2) + seg := strings.SplitN(strings.Trim(match, "{}"), ".", 2) if len(seg) != 2 { - return d, fmt.Errorf("Reference '%s' seems to be malformed\n", match) + return d, fmt.Errorf("reference '%s' seems to be malformed", match) } workspacePath := seg[0] @@ -409,9 +409,9 @@ func (ws Workspace) getManualInputs(workspaces map[string]*Workspace) ([]Input, submaches := re.FindAllSubmatch([]byte(m), -1) for _, sm := range submaches { match := string(sm[0]) - seg := strings.SplitN(strings.Trim(match, "{{}}"), ".", 2) + seg := strings.SplitN(strings.Trim(match, "{}"), ".", 2) if len(seg) != 2 { - return inputs, fmt.Errorf("Reference '%s' seems to be malformed\n", match) + return inputs, fmt.Errorf("reference '%s' seems to be malformed", match) } workspacePath := filepath.FromSlash(seg[0]) @@ -428,7 +428,7 @@ func (ws Workspace) getManualInputs(workspaces map[string]*Workspace) ([]Input, } } if o == nil { - return inputs, fmt.Errorf("Reference to '%s' in workspace '%s' does not exist\n", outputName, workspacePath) + return inputs, fmt.Errorf("reference to '%s' in workspace '%s' does not exist", outputName, workspacePath) } input := Input{ @@ -504,7 +504,7 @@ func (m Manual) render(inputs []Input) (string, error) { out, err := cmd.Output() if err != nil { - errOut := fmt.Errorf("Could not run command '%s %s' in '%s': %s", command, strings.Join(args, " "), chdir, err.Error()) + errOut := fmt.Errorf("could not run command '%s %s' in '%s': %s", command, strings.Join(args, " "), chdir, err.Error()) return rendered, errOut } outStr := strings.TrimSpace(string(out))