From 1800b34b51c7c61e650d0a2d2e36eb25e2dcb66d Mon Sep 17 00:00:00 2001 From: Ygal Blum Date: Thu, 16 Oct 2025 14:02:04 -0400 Subject: [PATCH] Quadlet build - add support for IgnoreFile key Resolves: https://github.com/containers/podman/issues/27268 Signed-off-by: Ygal Blum --- docs/source/markdown/podman-systemd.unit.5.md | 8 ++++++++ pkg/systemd/quadlet/quadlet.go | 3 +++ test/e2e/quadlet/ignorefile.build | 6 ++++++ test/e2e/quadlet_test.go | 1 + 4 files changed, 18 insertions(+) create mode 100644 test/e2e/quadlet/ignorefile.build diff --git a/docs/source/markdown/podman-systemd.unit.5.md b/docs/source/markdown/podman-systemd.unit.5.md index cccba233a2..246d8b9f9b 100644 --- a/docs/source/markdown/podman-systemd.unit.5.md +++ b/docs/source/markdown/podman-systemd.unit.5.md @@ -1724,6 +1724,7 @@ Valid options for `[Build]` are listed below: | ForceRM=false | --force-rm=false | | GlobalArgs=--log-level=debug | --log-level=debug | | GroupAdd=keep-groups | --group-add=keep-groups | +| IgnoreFile=/path/to/.customignore | --ignorefile=/path/to/.customignore | | ImageTag=localhost/imagename | --tag=localhost/imagename | | Label=label | --label=label | | Network=host | --network=host | @@ -1831,6 +1832,13 @@ Assign additional groups to the primary user running within the container proces This is equivalent to the `--group-add` option of `podman build`. +### `IgnoreFile=` + +Path to an alternate .containerignore file to use when building the image. +Note that when using a relative path you should also set `SetWorkingDirectory=` + +This is equivalent to the `--ignorefile` option of `podman build`. + ### `ImageTag=` Specifies the name which is assigned to the resulting image if the build process completes diff --git a/pkg/systemd/quadlet/quadlet.go b/pkg/systemd/quadlet/quadlet.go index beee07477e..c11e24b8ec 100644 --- a/pkg/systemd/quadlet/quadlet.go +++ b/pkg/systemd/quadlet/quadlet.go @@ -113,6 +113,7 @@ const ( KeyHealthTimeout = "HealthTimeout" KeyHostName = "HostName" KeyHttpProxy = "HttpProxy" + KeyIgnoreFile = "IgnoreFile" KeyImage = "Image" KeyImageTag = "ImageTag" KeyInterfaceName = "InterfaceName" @@ -446,6 +447,7 @@ var ( KeyForceRM: true, KeyGlobalArgs: true, KeyGroupAdd: true, + KeyIgnoreFile: true, KeyImageTag: true, KeyLabel: true, KeyNetwork: true, @@ -1392,6 +1394,7 @@ func ConvertBuild(build *parser.UnitFile, unitsInfoMap map[string]*UnitInfo, isU stringKeys := map[string]string{ KeyArch: "--arch", KeyAuthFile: "--authfile", + KeyIgnoreFile: "--ignorefile", KeyTarget: "--target", KeyVariant: "--variant", KeyRetry: "--retry", diff --git a/test/e2e/quadlet/ignorefile.build b/test/e2e/quadlet/ignorefile.build new file mode 100644 index 0000000000..9279d52f64 --- /dev/null +++ b/test/e2e/quadlet/ignorefile.build @@ -0,0 +1,6 @@ +## assert-podman-args "--ignorefile" "/path/to/.customignore" + +[Build] +ImageTag=localhost/imagename +SetWorkingDirectory=unit +IgnoreFile=/path/to/.customignore diff --git a/test/e2e/quadlet_test.go b/test/e2e/quadlet_test.go index 8d34b240f6..80f03ca5e7 100644 --- a/test/e2e/quadlet_test.go +++ b/test/e2e/quadlet_test.go @@ -1056,6 +1056,7 @@ BOGUS=foo Entry("Build - ForceRM Key", "force-rm.build"), Entry("Build - GlobalArgs", "globalargs.build"), Entry("Build - GroupAdd Key", "group-add.build"), + Entry("Build - IgnoreFile Key", "ignorefile.build"), Entry("Build - Containers Conf Modules", "containersconfmodule.build"), Entry("Build - Label Key", "label.build"), Entry("Build - Multiple Tags", "multiple-tags.build"),