Skip to content

Commit

Permalink
Merge pull request containers#18891 from rhatdan/update
Browse files Browse the repository at this point in the history
Add support for setting autoupdate in quadlet
  • Loading branch information
openshift-merge-robot authored Jun 15, 2023
2 parents 1f18ad5 + 479677c commit 189a74d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
14 changes: 12 additions & 2 deletions docs/source/markdown/podman-systemd.unit.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Valid options for `[Container]` are listed below:
| AddCapability=CAP | --cap-add CAP |
| AddDevice=/dev/foo | --device /dev/foo |
| Annotation="YXZ" | --annotation "XYZ" |
| AutoUpdate=registry | --label "io.containers.autoupdate=registry" |
| ContainerName=name | --name name |
| DropCapability=CAP | --cap-drop=CAP |
| Environment=foo=bar | --env foo=bar |
Expand Down Expand Up @@ -170,6 +171,14 @@ similar to `Environment`.

This key can be listed multiple times.

### `AutoUpdate=`

Indicates whether the container will be auto-updated ([podman-auto-update(1)](podman-auto-update.1.md)). The following values are supported:

* `registry`: Requires a fully-qualified image reference (e.g., quay.io/podman/stable:latest) to be used to create the container. This enforcement is necessary to know which image to actually check and pull. If an image ID was used, Podman does not know which image to check/pull anymore.

* `local`: Tells Podman to compare the image a container is using to the image with its raw name in local storage. If an image is updated locally, Podman simply restarts the systemd unit executing the container.

### `ContainerName=`

The (optional) name of the Podman container. If this is not specified, the default value
Expand Down Expand Up @@ -199,7 +208,7 @@ Use a line-delimited file to set environment variables in the container.
The path may be absolute or relative to the location of the unit file.
This key may be used multiple times, and the order persists when passed to `podman run`.

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

Use the host environment inside of the container.

Expand Down Expand Up @@ -852,4 +861,5 @@ Label=org.test.Key=value
**[systemd.unit(5)](https://www.freedesktop.org/software/systemd/man/systemd.unit.html)**,
**[systemd.service(5)](https://www.freedesktop.org/software/systemd/man/systemd.service.html)**,
**[podman-run(1)](podman-run.1.md)**,
**[podman-network-create(1)](podman-network-create.1.md)**
**[podman-network-create(1)](podman-network-create.1.md)**,
**[podman-auto-update(1)](podman-auto-update.1.md)**
9 changes: 9 additions & 0 deletions pkg/systemd/quadlet/quadlet.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const (
KeyAddCapability = "AddCapability"
KeyAddDevice = "AddDevice"
KeyAnnotation = "Annotation"
KeyAutoUpdate = "AutoUpdate"
KeyConfigMap = "ConfigMap"
KeyContainerName = "ContainerName"
KeyCopy = "Copy"
Expand Down Expand Up @@ -118,6 +119,7 @@ var (
KeyAddCapability: true,
KeyAddDevice: true,
KeyAnnotation: true,
KeyAutoUpdate: true,
KeyContainerName: true,
KeyDropCapability: true,
KeyEnvironment: true,
Expand Down Expand Up @@ -562,6 +564,13 @@ func ConvertContainer(container *parser.UnitFile, isUser bool) (*parser.UnitFile
}
}

update, ok := container.Lookup(ContainerGroup, KeyAutoUpdate)
if ok && len(update) > 0 {
podman.addLabels(map[string]string{
"io.containers.autoupdate": update,
})
}

exposedPorts := container.LookupAll(ContainerGroup, KeyExposeHostPort)
for _, exposedPort := range exposedPorts {
exposedPort = strings.TrimSpace(exposedPort) // Allow whitespace after
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/quadlet/autoupdate.container
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## assert-podman-final-args localhost/imagename
## assert-podman-args "--label" "io.containers.autoupdate=registry"

[Container]
Image=localhost/imagename
AutoUpdate=registry
1 change: 1 addition & 0 deletions test/e2e/quadlet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ var _ = Describe("quadlet system generator", func() {
},
Entry("Basic container", "basic.container"),
Entry("annotation.container", "annotation.container"),
Entry("autoupdate.container", "autoupdate.container"),
Entry("basepodman.container", "basepodman.container"),
Entry("capabilities.container", "capabilities.container"),
Entry("capabilities2.container", "capabilities2.container"),
Expand Down

0 comments on commit 189a74d

Please sign in to comment.