Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quadlet: support HostName #18515

Merged
merged 1 commit into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/source/markdown/podman-systemd.unit.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ Valid options for `[Container]` are listed below:
| HealthStartupSuccess=2 | --health-startup-success=2 |
| HealthStartupTimeout=1m33s | --health-startup-timeout=1m33s |
| HealthTimeout=20s | --health-timeout=20s |
| HostName=new-host-name | --hostname="new-host-name" |
| Image=ubi8 | Image specification - ubi8 |
| IP=192.5.0.1 | --ip 192.5.0.0 |
| IP6=fd46:db93:aa76:ac37::10 | --ip6 2001:db8::1 |
Expand Down Expand Up @@ -276,6 +277,11 @@ Equivalent to the Podman `--health-startup-timeout` option.
The maximum time allowed to complete the healthcheck before an interval is considered failed.
Equivalent to the Podman `--health-timeout` option.

### `HostName=`

Sets the host name that is available inside the container.
Equivalent to the Podman `--hostname` option.

### `Image=`

The image to run in the container. This image must be locally installed for the service to work
Expand Down
6 changes: 6 additions & 0 deletions pkg/systemd/quadlet/quadlet.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const (
KeyHealthStartupSuccess = "HealthStartupSuccess"
KeyHealthStartupTimeout = "HealthStartupTimeout"
KeyHealthTimeout = "HealthTimeout"
KeyHostName = "HostName"
KeyImage = "Image"
KeyIP = "IP"
KeyIP6 = "IP6"
Expand Down Expand Up @@ -129,6 +130,7 @@ var (
KeyHealthStartupSuccess: true,
KeyHealthStartupTimeout: true,
KeyHealthTimeout: true,
KeyHostName: true,
KeyImage: true,
KeyIP: true,
KeyIP6: true,
Expand Down Expand Up @@ -614,6 +616,10 @@ func ConvertContainer(container *parser.UnitFile, isUser bool) (*parser.UnitFile

handleHealth(container, ContainerGroup, podman)

if hostname, ok := container.Lookup(ContainerGroup, KeyHostName); ok {
podman.add("--hostname", hostname)
}

podmanArgs := container.LookupAllArgs(ContainerGroup, KeyPodmanArgs)
podman.add(podmanArgs...)

Expand Down
4 changes: 4 additions & 0 deletions test/e2e/quadlet/hostname.container
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[Container]
Image=localhost/imagename
## assert-podman-args "--hostname" "\"quadlet-host\""
HostName="quadlet-host"
1 change: 1 addition & 0 deletions test/e2e/quadlet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,7 @@ var _ = Describe("quadlet system generator", func() {
Entry("logdriver.container", "logdriver.container"),
Entry("mount.container", "mount.container"),
Entry("health.container", "health.container"),
Entry("hostname.container", "hostname.container"),

Entry("basic.volume", "basic.volume"),
Entry("label.volume", "label.volume"),
Expand Down