From 12fa4d703da8d05930303acbe6bbc8fd00c77de7 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 13 Nov 2021 20:43:31 +0100 Subject: [PATCH] fix: correctly unmarshal entrypoint (#876) Signed-off-by: hackercat Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- pkg/model/action.go | 2 +- pkg/runner/step_context.go | 11 ++++++++++- pkg/runner/testdata/actions/docker-url/action.yml | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/model/action.go b/pkg/model/action.go index d350b51..c57ed2c 100644 --- a/pkg/model/action.go +++ b/pkg/model/action.go @@ -47,7 +47,7 @@ type ActionRuns struct { Env map[string]string `yaml:"env"` Main string `yaml:"main"` Image string `yaml:"image"` - Entrypoint []string `yaml:"entrypoint"` + Entrypoint string `yaml:"entrypoint"` Args []string `yaml:"args"` Steps []Step `yaml:"steps"` } diff --git a/pkg/runner/step_context.go b/pkg/runner/step_context.go index 939ebdd..0fc7715 100644 --- a/pkg/runner/step_context.go +++ b/pkg/runner/step_context.go @@ -527,6 +527,8 @@ func (sc *StepContext) runAction(actionDir string, actionPath string, localActio } } +// TODO: break out parts of function to reduce complexicity +// nolint:gocyclo func (sc *StepContext) execAsDocker(ctx context.Context, action *model.Action, actionName string, containerLocation string, actionLocation string, rc *RunContext, step *model.Step, localAction bool) error { var prepImage common.Executor var image string @@ -589,7 +591,14 @@ func (sc *StepContext) execAsDocker(ctx context.Context, action *model.Action, a } entrypoint := strings.Fields(step.With["entrypoint"]) if len(entrypoint) == 0 { - entrypoint = action.Runs.Entrypoint + if action.Runs.Entrypoint != "" { + entrypoint, err = shellquote.Split(action.Runs.Entrypoint) + if err != nil { + return err + } + } else { + entrypoint = nil + } } stepContainer := sc.newStepContainer(ctx, image, cmd, entrypoint) return common.NewPipelineExecutor( diff --git a/pkg/runner/testdata/actions/docker-url/action.yml b/pkg/runner/testdata/actions/docker-url/action.yml index 335bf3f..de7251d 100644 --- a/pkg/runner/testdata/actions/docker-url/action.yml +++ b/pkg/runner/testdata/actions/docker-url/action.yml @@ -9,6 +9,7 @@ inputs: runs: using: docker image: docker://node:12-buster-slim + entrypoint: /bin/sh -c env: TEST: enabled args: