Skip to content

Commit

Permalink
Merge pull request containers#18788 from ygalblum/quadlet-pull
Browse files Browse the repository at this point in the history
Quadlet - add support for Pull key in .container
  • Loading branch information
openshift-merge-robot authored Jun 5, 2023
2 parents e143a0f + 6611735 commit d669d94
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
9 changes: 7 additions & 2 deletions docs/source/markdown/podman-systemd.unit.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ Valid options for `[Container]` are listed below:
| Notify=true | --sdnotify container |
| PodmanArgs=--add-host foobar | --add-host foobar |
| PublishPort=true | --publish |
| Pull=never | --pull=never |
| ReadOnly=true | --read-only |
| RunInit=true | --init |
| SeccompProfile=/tmp/s.json | --security-opt seccomp=/tmp/s.json |
Expand Down Expand Up @@ -283,8 +284,7 @@ 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
when it is activated, because the generated service file never tries to download images.
The image to run in the container.
It is recommended to use a fully qualified image name rather than a short name, both for
performance and robustness reasons.

Expand Down Expand Up @@ -391,6 +391,11 @@ allocated port can be found with the `podman port` command.

This key can be listed multiple times.

### `Pull=`

Set the image pull policy.
This is equivalent to the Podman `--pull` option

### `ReadOnly=` (defaults to `no`)

If enabled, makes image read-only, with /var/tmp, /tmp and /run a tmpfs (unless disabled by `VolatileTmp=no`).r
Expand Down
7 changes: 7 additions & 0 deletions pkg/systemd/quadlet/quadlet.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const (
KeyOptions = "Options"
KeyPodmanArgs = "PodmanArgs"
KeyPublishPort = "PublishPort"
KeyPull = "Pull"
KeyReadOnly = "ReadOnly"
KeyRemapGID = "RemapGid"
KeyRemapUID = "RemapUid"
Expand Down Expand Up @@ -143,6 +144,7 @@ var (
KeyNotify: true,
KeyPodmanArgs: true,
KeyPublishPort: true,
KeyPull: true,
KeyReadOnly: true,
KeyRemapGID: true,
KeyRemapUID: true,
Expand Down Expand Up @@ -625,6 +627,11 @@ func ConvertContainer(container *parser.UnitFile, isUser bool) (*parser.UnitFile
podman.add("--hostname", hostname)
}

pull, ok := container.Lookup(ContainerGroup, KeyPull)
if ok && len(pull) > 0 {
podman.add("--pull", pull)
}

handlePodmanArgs(container, ContainerGroup, podman)

if len(image) > 0 {
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/quadlet/pull.container
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## assert-podman-final-args localhost/imagename
## assert-podman-args --pull never

[Container]
Image=localhost/imagename
Pull=never
1 change: 1 addition & 0 deletions test/e2e/quadlet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ var _ = Describe("quadlet system generator", func() {
Entry("mount.container", "mount.container"),
Entry("health.container", "health.container"),
Entry("hostname.container", "hostname.container"),
Entry("pull.container", "pull.container"),

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

0 comments on commit d669d94

Please sign in to comment.