From 03f0829d097967849681b75b42d9b8b36576b056 Mon Sep 17 00:00:00 2001 From: Gianni Angelozzi Date: Thu, 17 Aug 2023 06:51:57 +0000 Subject: [PATCH] Add ForcePull option (#339) Close #271 What it does: instead of forcing the value of `ForcePull` to false, the user can now configure it on the runner yaml Reviewed-on: https://gitea.com/gitea/act_runner/pulls/339 Reviewed-by: Jason Song Co-authored-by: Gianni Angelozzi Co-committed-by: Gianni Angelozzi --- internal/app/run/runner.go | 2 +- internal/pkg/config/config.example.yaml | 2 ++ internal/pkg/config/config.go | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/app/run/runner.go b/internal/app/run/runner.go index c9f5f3e..7be1dba 100644 --- a/internal/app/run/runner.go +++ b/internal/app/run/runner.go @@ -183,7 +183,7 @@ func (r *Runner) run(ctx context.Context, task *runnerv1.Task, reporter *report. ActionCacheDir: filepath.FromSlash(r.cfg.Host.WorkdirParent), ReuseContainers: false, - ForcePull: false, + ForcePull: r.cfg.Container.ForcePull, ForceRebuild: false, LogOutput: true, JSONLogger: false, diff --git a/internal/pkg/config/config.example.yaml b/internal/pkg/config/config.example.yaml index 0dc9f0d..df4f6cc 100644 --- a/internal/pkg/config/config.example.yaml +++ b/internal/pkg/config/config.example.yaml @@ -80,6 +80,8 @@ container: # If it's "-", act_runner will find an available docker host automatically, but the docker host won't be mounted to the job containers and service containers. # If it's not empty or "-", the specified docker host will be used. An error will be returned if it doesn't work. docker_host: "" + # Pull docker image(s) even if already present + force_pull: false host: # The parent directory of a job's working directory. diff --git a/internal/pkg/config/config.go b/internal/pkg/config/config.go index 6b3c6e6..46fd059 100644 --- a/internal/pkg/config/config.go +++ b/internal/pkg/config/config.go @@ -50,6 +50,7 @@ type Container struct { WorkdirParent string `yaml:"workdir_parent"` // WorkdirParent specifies the parent directory for the container's working directory. ValidVolumes []string `yaml:"valid_volumes"` // ValidVolumes specifies the volumes (including bind mounts) can be mounted to containers. DockerHost string `yaml:"docker_host"` // DockerHost specifies the Docker host. It overrides the value specified in environment variable DOCKER_HOST. + ForcePull bool `yaml:"force_pull"` // Pull docker image(s) even if already present } // Host represents the configuration for the host.