1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-08-11 17:50:58 +00:00

feat: --hostname is allowed in container options (#95)

It is useful to set an alternative hostname when running a service
such as:

```yaml
services:
  minio:
    image: data.forgejo.org/oci/bitnami/minio:2024.8.17
    options: >-
      --hostname alternate.minio
```

Reviewed-on: https://code.forgejo.org/forgejo/act/pulls/95
Reviewed-by: Kwonunn <kwonunn@noreply.code.forgejo.org>
Co-authored-by: Earl Warren <contact@earl-warren.org>
Co-committed-by: Earl Warren <contact@earl-warren.org>
This commit is contained in:
Earl Warren 2025-01-22 18:22:29 +00:00 committed by earl-warren
parent a8bfb47292
commit d92e4a8aff
2 changed files with 8 additions and 2 deletions

View file

@ -435,6 +435,11 @@ func (cr *containerReference) mergeJobOptions(ctx context.Context, config *conta
}
}
if len(jobConfig.Config.Hostname) > 0 {
logger.Debugf("--hostname %v", jobConfig.Config.Hostname)
config.Hostname = jobConfig.Config.Hostname
}
return config, hostConfig, nil
}

View file

@ -258,9 +258,10 @@ func TestMergeJobOptions(t *testing.T) {
}{
{
name: "ok",
options: "--volume /foo:/bar --volume /frob:/nitz --volume somevolume --tmpfs /tmp:exec,noatime",
options: "--volume /foo:/bar --volume /frob:/nitz --volume somevolume --tmpfs /tmp:exec,noatime --hostname alternatehost",
config: &container.Config{
Volumes: map[string]struct{}{"somevolume": {}},
Volumes: map[string]struct{}{"somevolume": {}},
Hostname: "alternatehost",
},
hostConfig: &container.HostConfig{
Binds: []string{"/foo:/bar", "/frob:/nitz"},