From 2069b04779e17c2b1a1aafcf66c7ae18b89ddcf3 Mon Sep 17 00:00:00 2001 From: Zettat123 Date: Tue, 11 Jul 2023 02:08:22 +0000 Subject: [PATCH] Fix missed `ValidVolumes` for docker steps (#74) Fixes https://gitea.com/gitea/act_runner/issues/277 Thanks @ChristopherHX for finding the cause of the bug. Reviewed-on: https://gitea.com/gitea/act/pulls/74 Co-authored-by: Zettat123 Co-committed-by: Zettat123 --- pkg/runner/action.go | 37 +++++++++++++++++++------------------ pkg/runner/step_docker.go | 35 ++++++++++++++++++----------------- 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/pkg/runner/action.go b/pkg/runner/action.go index e1b15d9..7048f4d 100644 --- a/pkg/runner/action.go +++ b/pkg/runner/action.go @@ -377,24 +377,25 @@ func newStepContainer(ctx context.Context, step step, image string, cmd []string networkMode = "default" } stepContainer := container.NewContainer(&container.NewContainerInput{ - Cmd: cmd, - Entrypoint: entrypoint, - WorkingDir: rc.JobContainer.ToContainerPath(rc.Config.Workdir), - Image: image, - Username: rc.Config.Secrets["DOCKER_USERNAME"], - Password: rc.Config.Secrets["DOCKER_PASSWORD"], - Name: createSimpleContainerName(rc.jobContainerName(), "STEP-"+stepModel.ID), - Env: envList, - Mounts: mounts, - NetworkMode: networkMode, - Binds: binds, - Stdout: logWriter, - Stderr: logWriter, - Privileged: rc.Config.Privileged, - UsernsMode: rc.Config.UsernsMode, - Platform: rc.Config.ContainerArchitecture, - Options: rc.Config.ContainerOptions, - AutoRemove: rc.Config.AutoRemove, + Cmd: cmd, + Entrypoint: entrypoint, + WorkingDir: rc.JobContainer.ToContainerPath(rc.Config.Workdir), + Image: image, + Username: rc.Config.Secrets["DOCKER_USERNAME"], + Password: rc.Config.Secrets["DOCKER_PASSWORD"], + Name: createSimpleContainerName(rc.jobContainerName(), "STEP-"+stepModel.ID), + Env: envList, + Mounts: mounts, + NetworkMode: networkMode, + Binds: binds, + Stdout: logWriter, + Stderr: logWriter, + Privileged: rc.Config.Privileged, + UsernsMode: rc.Config.UsernsMode, + Platform: rc.Config.ContainerArchitecture, + Options: rc.Config.ContainerOptions, + AutoRemove: rc.Config.AutoRemove, + ValidVolumes: rc.Config.ValidVolumes, }) return stepContainer } diff --git a/pkg/runner/step_docker.go b/pkg/runner/step_docker.go index b83435f..725bfff 100644 --- a/pkg/runner/step_docker.go +++ b/pkg/runner/step_docker.go @@ -114,23 +114,24 @@ func (sd *stepDocker) newStepContainer(ctx context.Context, image string, cmd [] binds, mounts := rc.GetBindsAndMounts() stepContainer := ContainerNewContainer(&container.NewContainerInput{ - Cmd: cmd, - Entrypoint: entrypoint, - WorkingDir: rc.JobContainer.ToContainerPath(rc.Config.Workdir), - Image: image, - Username: rc.Config.Secrets["DOCKER_USERNAME"], - Password: rc.Config.Secrets["DOCKER_PASSWORD"], - Name: createSimpleContainerName(rc.jobContainerName(), "STEP-"+step.ID), - Env: envList, - Mounts: mounts, - NetworkMode: fmt.Sprintf("container:%s", rc.jobContainerName()), - Binds: binds, - Stdout: logWriter, - Stderr: logWriter, - Privileged: rc.Config.Privileged, - UsernsMode: rc.Config.UsernsMode, - Platform: rc.Config.ContainerArchitecture, - AutoRemove: rc.Config.AutoRemove, + Cmd: cmd, + Entrypoint: entrypoint, + WorkingDir: rc.JobContainer.ToContainerPath(rc.Config.Workdir), + Image: image, + Username: rc.Config.Secrets["DOCKER_USERNAME"], + Password: rc.Config.Secrets["DOCKER_PASSWORD"], + Name: createSimpleContainerName(rc.jobContainerName(), "STEP-"+step.ID), + Env: envList, + Mounts: mounts, + NetworkMode: fmt.Sprintf("container:%s", rc.jobContainerName()), + Binds: binds, + Stdout: logWriter, + Stderr: logWriter, + Privileged: rc.Config.Privileged, + UsernsMode: rc.Config.UsernsMode, + Platform: rc.Config.ContainerArchitecture, + AutoRemove: rc.Config.AutoRemove, + ValidVolumes: rc.Config.ValidVolumes, }) return stepContainer }