fix: crash on invalid docker credentials (#1348)
* fix: crash on invalid docker credentials * add test Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
6037182487
commit
7d0407fa4a
3 changed files with 16 additions and 4 deletions
|
@ -38,8 +38,6 @@ func newJobExecutor(info jobInfo, sf stepFactory, rc *RunContext) common.Executo
|
||||||
return common.NewDebugExecutor("No steps found")
|
return common.NewDebugExecutor("No steps found")
|
||||||
}
|
}
|
||||||
|
|
||||||
preSteps = append(preSteps, info.startContainer())
|
|
||||||
|
|
||||||
for i, stepModel := range infoSteps {
|
for i, stepModel := range infoSteps {
|
||||||
stepModel := stepModel
|
stepModel := stepModel
|
||||||
if stepModel == nil {
|
if stepModel == nil {
|
||||||
|
@ -104,7 +102,7 @@ func newJobExecutor(info jobInfo, sf stepFactory, rc *RunContext) common.Executo
|
||||||
pipeline = append(pipeline, preSteps...)
|
pipeline = append(pipeline, preSteps...)
|
||||||
pipeline = append(pipeline, steps...)
|
pipeline = append(pipeline, steps...)
|
||||||
|
|
||||||
return common.NewPipelineExecutor(pipeline...).
|
return common.NewPipelineExecutor(info.startContainer(), common.NewPipelineExecutor(pipeline...).
|
||||||
Finally(func(ctx context.Context) error {
|
Finally(func(ctx context.Context) error {
|
||||||
var cancel context.CancelFunc
|
var cancel context.CancelFunc
|
||||||
if ctx.Err() == context.Canceled {
|
if ctx.Err() == context.Canceled {
|
||||||
|
@ -116,7 +114,7 @@ func newJobExecutor(info jobInfo, sf stepFactory, rc *RunContext) common.Executo
|
||||||
return postExecutor(ctx)
|
return postExecutor(ctx)
|
||||||
}).
|
}).
|
||||||
Finally(info.interpolateOutputs()).
|
Finally(info.interpolateOutputs()).
|
||||||
Finally(info.closeContainer())
|
Finally(info.closeContainer()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func useStepLogger(rc *RunContext, stepModel *model.Step, stage stepStage, executor common.Executor) common.Executor {
|
func useStepLogger(rc *RunContext, stepModel *model.Step, stage stepStage, executor common.Executor) common.Executor {
|
||||||
|
|
|
@ -156,6 +156,7 @@ func TestRunEvent(t *testing.T) {
|
||||||
{workdir, "checkout", "push", "", platforms},
|
{workdir, "checkout", "push", "", platforms},
|
||||||
{workdir, "job-container", "push", "", platforms},
|
{workdir, "job-container", "push", "", platforms},
|
||||||
{workdir, "job-container-non-root", "push", "", platforms},
|
{workdir, "job-container-non-root", "push", "", platforms},
|
||||||
|
{workdir, "job-container-invalid-credentials", "push", "failed to handle credentials: failed to interpolate container.credentials.password", platforms},
|
||||||
{workdir, "container-hostname", "push", "", platforms},
|
{workdir, "container-hostname", "push", "", platforms},
|
||||||
{workdir, "remote-action-docker", "push", "", platforms},
|
{workdir, "remote-action-docker", "push", "", platforms},
|
||||||
{workdir, "remote-action-js", "push", "", platforms},
|
{workdir, "remote-action-js", "push", "", platforms},
|
||||||
|
|
13
pkg/runner/testdata/job-container-invalid-credentials/push.yml
vendored
Normal file
13
pkg/runner/testdata/job-container-invalid-credentials/push.yml
vendored
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
name: job-container-invalid-credentials
|
||||||
|
on: push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
fail-on-invalid-credentials:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: node:16-buster-slim
|
||||||
|
credentials:
|
||||||
|
username: "user"
|
||||||
|
password: "" # Empty password caused a crash in jobexecutor
|
||||||
|
steps:
|
||||||
|
- run: exit 0
|
Loading…
Reference in a new issue