Skip to content

Commit

Permalink
Merge pull request containers#20905 from Odilhao/issue-20585-entrypoint
Browse files Browse the repository at this point in the history
Add support for Entrypoint in quadlet
  • Loading branch information
openshift-merge-bot[bot] authored Dec 6, 2023
2 parents c04ed59 + 7cc6501 commit 72ceb6e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/source/markdown/podman-systemd.unit.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ Valid options for `[Container]` are listed below:
| Environment=foo=bar | --env foo=bar |
| EnvironmentFile=/tmp/env | --env-file /tmp/env |
| EnvironmentHost=true | --env-host |
| Entrypoint=/foo.sh | --entrypoint=/foo.sh |
| Exec=/usr/bin/command | Command after image specification - /usr/bin/command |
| ExposeHostPort=50-59 | --expose 50-59 |
| GIDMap=0:10000:10 | --gidmap=0:10000:10 |
Expand Down Expand Up @@ -320,6 +321,12 @@ This key may be used multiple times, and the order persists when passed to `podm

Use the host environment inside of the container.

#### `Entrypoint=`

Override the default ENTRYPOINT from the image.
Equivalent to the Podman `--entrypoint` option.
Specify multi option commands in the form of a json string.

### `Exec=`

If this is set then it defines what command line to run in the container. If it is not set the
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 @@ -72,6 +72,7 @@ const (
KeyEnvironment = "Environment"
KeyEnvironmentFile = "EnvironmentFile"
KeyEnvironmentHost = "EnvironmentHost"
KeyEntrypoint = "Entrypoint"
KeyExec = "Exec"
KeyExitCodePropagation = "ExitCodePropagation"
KeyExposeHostPort = "ExposeHostPort"
Expand Down Expand Up @@ -180,6 +181,7 @@ var (
KeyEnvironment: true,
KeyEnvironmentFile: true,
KeyEnvironmentHost: true,
KeyEntrypoint: true,
KeyExec: true,
KeyExposeHostPort: true,
KeyGIDMap: true,
Expand Down Expand Up @@ -628,6 +630,11 @@ func ConvertContainer(container *parser.UnitFile, names map[string]string, isUse
podman.addf("--shm-size=%s", shmSize)
}

entrypoint, hasEntrypoint := container.Lookup(ContainerGroup, KeyEntrypoint)
if hasEntrypoint {
podman.addf("--entrypoint=%s", entrypoint)
}

sysctl := container.LookupAllStrv(ContainerGroup, KeySysctl)
for _, sysctlItem := range sysctl {
podman.addf("--sysctl=%s", sysctlItem)
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/quadlet/entrypoint.container
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## assert-podman-final-args localhost/imagename
## assert-podman-args "--entrypoint=top"

[Container]
Image=localhost/imagename
Entrypoint=top
1 change: 1 addition & 0 deletions test/e2e/quadlet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,7 @@ BOGUS=foo
Entry("env-host-false.container", "env-host-false.container", 0, ""),
Entry("env-host.container", "env-host.container", 0, ""),
Entry("env.container", "env.container", 0, ""),
Entry("entrypoint.container", "entrypoint.container", 0, ""),
Entry("escapes.container", "escapes.container", 0, ""),
Entry("exec.container", "exec.container", 0, ""),
Entry("health.container", "health.container", 0, ""),
Expand Down

0 comments on commit 72ceb6e

Please sign in to comment.