From 720e2637679237c680768c033248d3a385f3c785 Mon Sep 17 00:00:00 2001 From: givensuman Date: Wed, 8 Oct 2025 12:44:11 -0400 Subject: [PATCH 1/6] Add BuildArg key to quadlets Signed-off-by: givensuman --- pkg/systemd/quadlet/quadlet.go | 3 +++ test/e2e/quadlet/buildarg.build | 8 ++++++++ test/e2e/quadlet_test.go | 1 + 3 files changed, 12 insertions(+) create mode 100644 test/e2e/quadlet/buildarg.build diff --git a/pkg/systemd/quadlet/quadlet.go b/pkg/systemd/quadlet/quadlet.go index c077043f9d..bc5f899c0d 100644 --- a/pkg/systemd/quadlet/quadlet.go +++ b/pkg/systemd/quadlet/quadlet.go @@ -63,6 +63,7 @@ const ( KeyArch = "Arch" KeyAuthFile = "AuthFile" KeyAutoUpdate = "AutoUpdate" + KeyBuildArg = "BuildArg" KeyCertDir = "CertDir" KeyCgroupsMode = "CgroupsMode" KeyConfigMap = "ConfigMap" @@ -433,6 +434,7 @@ var ( KeyAnnotation: true, KeyArch: true, KeyAuthFile: true, + KeyBuildArg: true, KeyContainersConfModule: true, KeyDNS: true, KeyDNSOption: true, @@ -1391,6 +1393,7 @@ func ConvertBuild(build *parser.UnitFile, unitsInfoMap map[string]*UnitInfo, isU lookupAndAddAllStrings(build, BuildGroup, allStringKeys, podman) keyValKeys := map[string]string{ + KeyBuildArg: "--build-arg", KeyEnvironment: "--env", KeyLabel: "--label", KeyAnnotation: "--annotation", diff --git a/test/e2e/quadlet/buildarg.build b/test/e2e/quadlet/buildarg.build new file mode 100644 index 0000000000..e6866181fc --- /dev/null +++ b/test/e2e/quadlet/buildarg.build @@ -0,0 +1,8 @@ +## assert-podman-args "--build-arg" "FOO=BAR" +## assert-podman-args "--build-arg" "BIZ=BAZ" + +[Build] +ImageTag=image:latest +SetWorkingDirectory=unit +BuildArg=FOO=BAR +BuildArg=BIZ=BAZ diff --git a/test/e2e/quadlet_test.go b/test/e2e/quadlet_test.go index 44dad370d5..cc526046fe 100644 --- a/test/e2e/quadlet_test.go +++ b/test/e2e/quadlet_test.go @@ -1059,6 +1059,7 @@ BOGUS=foo Entry("Build - Multiple Tags", "multiple-tags.build"), Entry("Build - Network Key host", "network.build"), Entry("Build - PodmanArgs", "podmanargs.build"), + Entry("Build - BuildArg Key", "buildarg.build"), Entry("Build - Pull Key", "pull.build"), Entry("Build - Secrets", "secrets.build"), Entry("Build - SetWorkingDirectory is absolute path", "setworkingdirectory-is-abs.build"), From 196be4b81331e28ef9841e334d5952757c7fb262 Mon Sep 17 00:00:00 2001 From: givensuman Date: Wed, 8 Oct 2025 13:20:41 -0400 Subject: [PATCH 2/6] Test for multiple key/val arguments Signed-off-by: givensuman --- test/e2e/quadlet/buildarg.build | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/e2e/quadlet/buildarg.build b/test/e2e/quadlet/buildarg.build index e6866181fc..a76db5cd2e 100644 --- a/test/e2e/quadlet/buildarg.build +++ b/test/e2e/quadlet/buildarg.build @@ -1,8 +1,13 @@ ## assert-podman-args "--build-arg" "FOO=BAR" ## assert-podman-args "--build-arg" "BIZ=BAZ" +## assert-podman-args "--build-arg" "MULTIPLE=ARGUMENTS" +## assert-podman-args "--build-arg" "WORKS=FINE" + [Build] ImageTag=image:latest SetWorkingDirectory=unit BuildArg=FOO=BAR BuildArg=BIZ=BAZ +BuildArg=MULTIPLE=ARGUMENTS \ + WORKS=FINE From a696f8bccbade60188190a1470fe395261a1b198 Mon Sep 17 00:00:00 2001 From: givensuman Date: Wed, 8 Oct 2025 13:31:30 -0400 Subject: [PATCH 3/6] Update documentation to include BuildArg key Signed-off-by: givensuman --- docs/source/markdown/podman-systemd.unit.5.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/source/markdown/podman-systemd.unit.5.md b/docs/source/markdown/podman-systemd.unit.5.md index 480f08eb22..ea0dd13334 100644 --- a/docs/source/markdown/podman-systemd.unit.5.md +++ b/docs/source/markdown/podman-systemd.unit.5.md @@ -1708,6 +1708,7 @@ Valid options for `[Build]` are listed below: | Annotation=annotation=value | --annotation=annotation=value | | Arch=aarch64 | --arch=aarch64 | | AuthFile=/etc/registry/auth\.json | --authfile=/etc/registry/auth\.json | +| BuildArg=foo=bar | --build-arg foo=bar | | ContainersConfModule=/etc/nvd\.conf | --module=/etc/nvd\.conf | | DNS=192.168.55.1 | --dns=192.168.55.1 | | DNSOption=ndots:1 | --dns-option=ndots:1 | @@ -1750,6 +1751,14 @@ Path of the authentication file. This is equivalent to the `--authfile` option of `podman build`. +### `BuildArg=` + +Specifies a build argument and its value in the same way environment variables are +(e.g. env=*value*), but which is not added to environment variable list in the +resulting image's configuration. Can be listed multiple times. + +This is equivalent to the `--build-arg` option of `podman build`. + ### `ContainersConfModule=` Load the specified containers.conf(5) module. Equivalent to the Podman `--module` option. From c0a09e7f1019a4ecde1cdd44ad994a0d7eee080d Mon Sep 17 00:00:00 2001 From: given Date: Thu, 9 Oct 2025 08:31:10 -0400 Subject: [PATCH 4/6] Update docs/source/markdown/podman-systemd.unit.5.md Co-authored-by: Tom Sweeney Signed-off-by: givensuman --- docs/source/markdown/podman-systemd.unit.5.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/markdown/podman-systemd.unit.5.md b/docs/source/markdown/podman-systemd.unit.5.md index ea0dd13334..01b2491fce 100644 --- a/docs/source/markdown/podman-systemd.unit.5.md +++ b/docs/source/markdown/podman-systemd.unit.5.md @@ -1754,7 +1754,7 @@ This is equivalent to the `--authfile` option of `podman build`. ### `BuildArg=` Specifies a build argument and its value in the same way environment variables are -(e.g. env=*value*), but which is not added to environment variable list in the +(e.g., env=*value*), but it is not added to the environment variable list in the resulting image's configuration. Can be listed multiple times. This is equivalent to the `--build-arg` option of `podman build`. From b4d81c0338fc2280c7a6e0333a2cd592a797f509 Mon Sep 17 00:00:00 2001 From: givensuman Date: Thu, 9 Oct 2025 09:29:34 -0400 Subject: [PATCH 5/6] Run `make validatepr` Signed-off-by: givensuman --- docs/source/markdown/podman-systemd.unit.5.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/markdown/podman-systemd.unit.5.md b/docs/source/markdown/podman-systemd.unit.5.md index 01b2491fce..03ed8c7a3c 100644 --- a/docs/source/markdown/podman-systemd.unit.5.md +++ b/docs/source/markdown/podman-systemd.unit.5.md @@ -1753,8 +1753,8 @@ This is equivalent to the `--authfile` option of `podman build`. ### `BuildArg=` -Specifies a build argument and its value in the same way environment variables are -(e.g., env=*value*), but it is not added to the environment variable list in the +Specifies a build argument and its value in the same way environment variables are +(e.g., env=*value*), but it is not added to the environment variable list in the resulting image's configuration. Can be listed multiple times. This is equivalent to the `--build-arg` option of `podman build`. From 1e713c1a5fb9361a9327e49994b78bd2043db164 Mon Sep 17 00:00:00 2001 From: givensuman Date: Fri, 10 Oct 2025 13:24:44 -0400 Subject: [PATCH 6/6] Add BuildArg example into documentation Signed-off-by: givensuman --- docs/source/markdown/podman-systemd.unit.5.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/source/markdown/podman-systemd.unit.5.md b/docs/source/markdown/podman-systemd.unit.5.md index 03ed8c7a3c..f20cb52aa0 100644 --- a/docs/source/markdown/podman-systemd.unit.5.md +++ b/docs/source/markdown/podman-systemd.unit.5.md @@ -2166,7 +2166,7 @@ Yaml=/opt/k8s/deployment.yml WantedBy=multi-user.target default.target ``` -Example for locally built image to be used in a container: +Example for locally built image to be used in a container with build-specific arguments: `test.build` ``` @@ -2178,6 +2178,9 @@ ImageTag=localhost/imagename # expecting to find a Containerfile/Dockerfile # + other files needed to build the image SetWorkingDirectory=unit +# Set build arguments VERSION and DEBUG +BuildArg=VERSION=1.0 \ + DEBUG=false ``` `test.container`