diff options
author | Earl Warren <contact@earl-warren.org> | 2024-11-27 01:28:35 +0100 |
---|---|---|
committer | Earl Warren <contact@earl-warren.org> | 2024-11-27 02:36:18 +0100 |
commit | 279faefa0828619322c3ff1ed3c2dd0db8fb138d (patch) | |
tree | 1fe8a29359b92500f139940fbca813facc2fcd01 /internal | |
parent | Merge pull request 'Update module github.com/stretchr/testify to v1.10.0' (#3... (diff) | |
download | forgejo-runner-279faefa0828619322c3ff1ed3c2dd0db8fb138d.tar.xz forgejo-runner-279faefa0828619322c3ff1ed3c2dd0db8fb138d.zip |
fix: [container].docker_host = "" is now "automount"
The empty string is always replaced with "-" and there no longer is
any way to specify that the docker socket is to be mounted in the
container automatically.
The "automount" value is introduced as a replacement.
https://code.forgejo.org/forgejo/act/pulls/67 and
https://code.forgejo.org/forgejo/runner/pulls/305 introduced this regression.
Diffstat (limited to '')
-rw-r--r-- | internal/app/cmd/daemon.go | 7 | ||||
-rw-r--r-- | internal/pkg/config/config.example.yaml | 4 | ||||
-rw-r--r-- | internal/pkg/envcheck/docker.go | 5 |
3 files changed, 5 insertions, 11 deletions
diff --git a/internal/app/cmd/daemon.go b/internal/app/cmd/daemon.go index a613546..a02f36d 100644 --- a/internal/app/cmd/daemon.go +++ b/internal/app/cmd/daemon.go @@ -73,11 +73,8 @@ func runDaemon(ctx context.Context, configFile *string) func(cmd *cobra.Command, if err := envcheck.CheckIfDockerRunning(ctx, dockerSocketPath); err != nil { return err } - // if dockerSocketPath passes the check, override DOCKER_HOST with dockerSocketPath os.Setenv("DOCKER_HOST", dockerSocketPath) - // empty cfg.Container.DockerHost means act_runner need to find an available docker host automatically - // and assign the path to cfg.Container.DockerHost - if cfg.Container.DockerHost == "" { + if cfg.Container.DockerHost == "automount" { cfg.Container.DockerHost = dockerSocketPath } // check the scheme, if the scheme is not npipe or unix @@ -186,7 +183,7 @@ var commonSocketPaths = []string{ func getDockerSocketPath(configDockerHost string) (string, error) { // a `-` means don't mount the docker socket to job containers - if configDockerHost != "" && configDockerHost != "-" { + if configDockerHost != "automount" && configDockerHost != "-" { return configDockerHost, nil } diff --git a/internal/pkg/config/config.example.yaml b/internal/pkg/config/config.example.yaml index 20218ae..dbdf46e 100644 --- a/internal/pkg/config/config.example.yaml +++ b/internal/pkg/config/config.example.yaml @@ -89,8 +89,8 @@ container: # - '**' valid_volumes: [] # overrides the docker client host with the specified one. - # If "-", an available docker host will automatically be found. - # If empty, an available docker host will automatically be found and mounted in the job container (e.g. /var/run/docker.sock). + # If "-" or "", an available docker host will automatically be found. + # If "automount", an available docker host will automatically be found and mounted in the job container (e.g. /var/run/docker.sock). # Otherwise the specified docker host will be used and an error will be returned if it doesn't work. docker_host: "-" # Pull docker image(s) even if already present diff --git a/internal/pkg/envcheck/docker.go b/internal/pkg/envcheck/docker.go index f115bc7..cb9c901 100644 --- a/internal/pkg/envcheck/docker.go +++ b/internal/pkg/envcheck/docker.go @@ -13,10 +13,7 @@ import ( func CheckIfDockerRunning(ctx context.Context, configDockerHost string) error { opts := []client.Opt{ client.FromEnv, - } - - if configDockerHost != "" { - opts = append(opts, client.WithHost(configDockerHost)) + client.WithHost(configDockerHost), } cli, err := client.NewClientWithOpts(opts...) |