From e6fcfed458dbccd640e093bffd0fc258d6ce0e6e Mon Sep 17 00:00:00 2001 From: "KADOTA, Kyohei" <lufia@users.noreply.github.com> Date: Fri, 15 Jan 2021 14:37:38 +0900 Subject: [PATCH] Format sources with gofmt (#472) Co-authored-by: Casey Lee <cplee@nektos.com> --- pkg/container/docker_run.go | 4 ++-- pkg/model/workflow.go | 2 +- pkg/runner/expression.go | 6 +++--- pkg/runner/expression_test.go | 2 +- pkg/runner/run_context.go | 2 +- pkg/runner/step_context.go | 3 --- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/pkg/container/docker_run.go b/pkg/container/docker_run.go index d070f7e..b9b819f 100644 --- a/pkg/container/docker_run.go +++ b/pkg/container/docker_run.go @@ -11,8 +11,8 @@ import ( "os" "path/filepath" "regexp" - "strings" "runtime" + "strings" "github.com/go-git/go-billy/v5/helper/polyfill" "github.com/go-git/go-billy/v5/osfs" @@ -342,7 +342,7 @@ func (cr *containerReference) exec(cmd []string, env map[string]string) common.E } cmd = newCmd } - + logger.Debugf("Exec command '%s'", cmd) isTerminal := term.IsTerminal(int(os.Stdout.Fd())) envList := make([]string, 0) diff --git a/pkg/model/workflow.go b/pkg/model/workflow.go index aa5422b..842b9db 100644 --- a/pkg/model/workflow.go +++ b/pkg/model/workflow.go @@ -192,7 +192,7 @@ func (j *Job) GetMatrixes() []map[string]interface{} { func commonKeysMatch(a map[string]interface{}, b map[string]interface{}) bool { for aKey, aVal := range a { - if bVal, ok := b[aKey]; ok && ! reflect.DeepEqual(aVal, bVal) { + if bVal, ok := b[aKey]; ok && !reflect.DeepEqual(aVal, bVal) { return false } } diff --git a/pkg/runner/expression.go b/pkg/runner/expression.go index 0f45ada..757587d 100644 --- a/pkg/runner/expression.go +++ b/pkg/runner/expression.go @@ -61,8 +61,8 @@ type expressionEvaluator struct { } func (ee *expressionEvaluator) Evaluate(in string) (string, bool, error) { - if strings.HasPrefix(in, `secrets.`){ - in = `secrets.`+strings.ToUpper(strings.SplitN(in, `.`, 2)[1]) + if strings.HasPrefix(in, `secrets.`) { + in = `secrets.` + strings.ToUpper(strings.SplitN(in, `.`, 2)[1]) } re := ee.Rewrite(in) if re != in { @@ -84,7 +84,7 @@ func (ee *expressionEvaluator) Evaluate(in string) (string, bool, error) { return valAsString, val.IsString(), err } -func (ee *expressionEvaluator) Interpolate(in string) string{ +func (ee *expressionEvaluator) Interpolate(in string) string { interpolated, _ := ee.InterpolateWithStringCheck(in) return interpolated } diff --git a/pkg/runner/expression_test.go b/pkg/runner/expression_test.go index a00b88d..df0a50b 100644 --- a/pkg/runner/expression_test.go +++ b/pkg/runner/expression_test.go @@ -219,7 +219,7 @@ jobs: expr := expressionPattern.ReplaceAllStringFunc(table.in, func(match string) string { return fmt.Sprintf("€{{ %s }}", expressionPattern.ReplaceAllString(match, "$1")) }) - name := fmt.Sprintf(`%s -> %s should be equal to %s`,expr, table.in, table.out) + name := fmt.Sprintf(`%s -> %s should be equal to %s`, expr, table.in, table.out) echo := `run: echo "Done "` workflow += fmt.Sprintf(` - name: %s diff --git a/pkg/runner/run_context.go b/pkg/runner/run_context.go index a7de642..f0cd0c5 100644 --- a/pkg/runner/run_context.go +++ b/pkg/runner/run_context.go @@ -206,7 +206,7 @@ func (rc *RunContext) newStepExecutor(step *model.Step) common.Executor { if err != nil { return err } - rc.ExprEval = exprEval; + rc.ExprEval = exprEval runStep, err := rc.EvalBool(sc.Step.If) if err != nil { diff --git a/pkg/runner/step_context.go b/pkg/runner/step_context.go index 56e51a5..9faa4bc 100644 --- a/pkg/runner/step_context.go +++ b/pkg/runner/step_context.go @@ -101,14 +101,12 @@ func (sc *StepContext) mergeEnv() map[string]string { return env } - func (sc *StepContext) interpolateEnv(exprEval ExpressionEvaluator) { for k, v := range sc.Env { sc.Env[k] = exprEval.Interpolate(v) } } - func (sc *StepContext) setupEnv(ctx context.Context) (ExpressionEvaluator, error) { rc := sc.RunContext sc.Env = sc.mergeEnv() @@ -125,7 +123,6 @@ func (sc *StepContext) setupEnv(ctx context.Context) (ExpressionEvaluator, error return evaluator, nil } - func (sc *StepContext) setupShellCommand() common.Executor { rc := sc.RunContext step := sc.Step