From 972ffaca4d5047c139bb821ac74f756298a6204c Mon Sep 17 00:00:00 2001 From: Odilon Sousa Date: Mon, 4 Dec 2023 23:32:39 -0300 Subject: [PATCH 1/2] Add support for Entrypoint in quadlet This PR closes #20585 Add Inital support for Entrypoint on quadlets Add Bats Tests for Entrypoint Updates the documentation with one example to use the Entrypoint option Signed-off-by: Odilon Sousa --- docs/source/markdown/podman-systemd.unit.5.md | 7 +++++++ pkg/systemd/quadlet/quadlet.go | 7 +++++++ test/system/252-quadlet.bats | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/docs/source/markdown/podman-systemd.unit.5.md b/docs/source/markdown/podman-systemd.unit.5.md index 5bbc2b6974..269c7ffd3b 100644 --- a/docs/source/markdown/podman-systemd.unit.5.md +++ b/docs/source/markdown/podman-systemd.unit.5.md @@ -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 | @@ -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 diff --git a/pkg/systemd/quadlet/quadlet.go b/pkg/systemd/quadlet/quadlet.go index 349d55bc79..c484ec66d0 100644 --- a/pkg/systemd/quadlet/quadlet.go +++ b/pkg/systemd/quadlet/quadlet.go @@ -72,6 +72,7 @@ const ( KeyEnvironment = "Environment" KeyEnvironmentFile = "EnvironmentFile" KeyEnvironmentHost = "EnvironmentHost" + KeyEntrypoint = "Entrypoint" KeyExec = "Exec" KeyExitCodePropagation = "ExitCodePropagation" KeyExposeHostPort = "ExposeHostPort" @@ -180,6 +181,7 @@ var ( KeyEnvironment: true, KeyEnvironmentFile: true, KeyEnvironmentHost: true, + KeyEntrypoint: true, KeyExec: true, KeyExposeHostPort: true, KeyGIDMap: true, @@ -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) diff --git a/test/system/252-quadlet.bats b/test/system/252-quadlet.bats index 912b6be08c..e8b6727a78 100644 --- a/test/system/252-quadlet.bats +++ b/test/system/252-quadlet.bats @@ -1467,4 +1467,22 @@ EOF run_podman rmi $(pause_image) } +@test "quadlet - entrypoint" { + local quadlet_file=$PODMAN_TMPDIR/basic_$(random_string).container + cat > $quadlet_file < Date: Tue, 5 Dec 2023 09:51:39 -0300 Subject: [PATCH 2/2] Add e2e tests for quadlet Entrypoint option Drop bats tests for quadlet Entrypoint Signed-off-by: Odilon Sousa --- test/e2e/quadlet/entrypoint.container | 6 ++++++ test/e2e/quadlet_test.go | 1 + test/system/252-quadlet.bats | 18 ------------------ 3 files changed, 7 insertions(+), 18 deletions(-) create mode 100644 test/e2e/quadlet/entrypoint.container diff --git a/test/e2e/quadlet/entrypoint.container b/test/e2e/quadlet/entrypoint.container new file mode 100644 index 0000000000..035783500b --- /dev/null +++ b/test/e2e/quadlet/entrypoint.container @@ -0,0 +1,6 @@ +## assert-podman-final-args localhost/imagename +## assert-podman-args "--entrypoint=top" + +[Container] +Image=localhost/imagename +Entrypoint=top diff --git a/test/e2e/quadlet_test.go b/test/e2e/quadlet_test.go index a89107e13d..a4e76edccb 100644 --- a/test/e2e/quadlet_test.go +++ b/test/e2e/quadlet_test.go @@ -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, ""), diff --git a/test/system/252-quadlet.bats b/test/system/252-quadlet.bats index e8b6727a78..912b6be08c 100644 --- a/test/system/252-quadlet.bats +++ b/test/system/252-quadlet.bats @@ -1467,22 +1467,4 @@ EOF run_podman rmi $(pause_image) } -@test "quadlet - entrypoint" { - local quadlet_file=$PODMAN_TMPDIR/basic_$(random_string).container - cat > $quadlet_file <