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:
parent
a8bfb47292
commit
d92e4a8aff
2 changed files with 8 additions and 2 deletions
|
@ -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
|
return config, hostConfig, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -258,9 +258,10 @@ func TestMergeJobOptions(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "ok",
|
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{
|
config: &container.Config{
|
||||||
Volumes: map[string]struct{}{"somevolume": {}},
|
Volumes: map[string]struct{}{"somevolume": {}},
|
||||||
|
Hostname: "alternatehost",
|
||||||
},
|
},
|
||||||
hostConfig: &container.HostConfig{
|
hostConfig: &container.HostConfig{
|
||||||
Binds: []string{"/foo:/bar", "/frob:/nitz"},
|
Binds: []string{"/foo:/bar", "/frob:/nitz"},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue