diff --git a/docs/source/markdown/podman-quadlet-list.1.md b/docs/source/markdown/podman-quadlet-list.1.md index 4f33efe045d..70da7b415f8 100644 --- a/docs/source/markdown/podman-quadlet-list.1.md +++ b/docs/source/markdown/podman-quadlet-list.1.md @@ -35,6 +35,7 @@ Print results with a Go template. | .App | Name of application if Quadlet is part of an app | | .Name | Name of the Quadlet file | | .Path | Quadlet file path on disk | +| .Pod | Pod name (if the quadlet is part of a pod - only applicable to .container files)| | .Status | Quadlet status corresponding to systemd unit | | .UnitName | Systemd unit name corresponding to quadlet | diff --git a/pkg/domain/entities/quadlet.go b/pkg/domain/entities/quadlet.go index 1306bb1ea5b..77be4974b1d 100644 --- a/pkg/domain/entities/quadlet.go +++ b/pkg/domain/entities/quadlet.go @@ -41,6 +41,8 @@ type ListQuadlet struct { // If multiple quadlets were installed together they will belong // to common App. App string + // Pod is the name of the pod this quadlet belongs to + Pod string } // QuadletRemoveOptions contains parameters for removing Quadlets diff --git a/pkg/domain/infra/abi/quadlet.go b/pkg/domain/infra/abi/quadlet.go index 9011d79f21e..d285b386f6e 100644 --- a/pkg/domain/infra/abi/quadlet.go +++ b/pkg/domain/infra/abi/quadlet.go @@ -465,10 +465,21 @@ func (ic *ContainerEngine) QuadletList(ctx context.Context, options entities.Qua if ok { appName = value } + + // Parse the unit file to extract Pod= from the [Container] section + podName := "" + unitFile, err := parser.ParseUnitFile(path) + if err == nil { + // LookupLast returns the last value if Pod= is specified multiple times + value, _ := unitFile.LookupLast("Container", "Pod") + podName = value + } + report := entities.ListQuadlet{ Name: filepath.Base(path), Path: path, App: appName, + Pod: podName, } serviceName, err := getQuadletServiceName(path) diff --git a/test/system/253-podman-quadlet.bats b/test/system/253-podman-quadlet.bats index 892a0c6fc1a..dcbace29494 100644 --- a/test/system/253-podman-quadlet.bats +++ b/test/system/253-podman-quadlet.bats @@ -504,4 +504,43 @@ EOF run_podman quadlet rm alpine-quadlet.container } +@test "quadlet verb - list shows Pod field" { + # Create a pod quadlet + local pod_file=$PODMAN_TMPDIR/test-pod.pod + cat > $pod_file < $container_file < $standalone_file <