Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0709f88

Browse files
quadlet: add Pod field to quadlet list output
Fixes:#27121Signed-off-by: codynguyen-dev <codynnn@outlook.com>
1 parent020a597 commit0709f88

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed

‎docs/source/markdown/podman-quadlet-list.1.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Print results with a Go template.
3535
| .App| Name of application if Quadlet is part of an app|
3636
| .Name| Name of the Quadlet file|
3737
| .Path| Quadlet file path on disk|
38+
| .Pod| Pod name (if the quadlet is part of a pod|
3839
| .Status| Quadlet status corresponding to systemd unit|
3940
| .UnitName| Systemd unit name corresponding to quadlet|
4041

‎pkg/domain/entities/quadlet.go‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ type ListQuadlet struct {
4141
// If multiple quadlets were installed together they will belong
4242
// to common App.
4343
Appstring
44+
// Pod is the name of the pod this quadlet belongs to
45+
Podstring
4446
}
4547

4648
// QuadletRemoveOptions contains parameters for removing Quadlets

‎pkg/domain/infra/abi/quadlet.go‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,10 +465,21 @@ func (ic *ContainerEngine) QuadletList(ctx context.Context, options entities.Qua
465465
ifok {
466466
appName=value
467467
}
468+
469+
// Parse the unit file to extract Pod= from the [Container] section
470+
podName:=""
471+
unitFile,err:=parser.ParseUnitFile(path)
472+
iferr==nil {
473+
// LookupLast returns the last value if Pod= is specified multiple times
474+
value,_:=unitFile.LookupLast("Container","Pod")
475+
podName=value
476+
}
477+
468478
report:= entities.ListQuadlet{
469479
Name:filepath.Base(path),
470480
Path:path,
471481
App:appName,
482+
Pod:podName,
472483
}
473484

474485
serviceName,err:=getQuadletServiceName(path)

‎test/system/253-podman-quadlet.bats‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,4 +504,43 @@ EOF
504504
run_podman quadlet rm alpine-quadlet.container
505505
}
506506

507+
@test"quadlet verb - list shows Pod field" {
508+
# Create a pod quadlet
509+
local pod_file=$PODMAN_TMPDIR/test-pod.pod
510+
cat>$pod_file<<EOF
511+
[Pod]
512+
EOF
513+
# Create a container quadlet that joins the pod
514+
local container_file=$PODMAN_TMPDIR/pod-member.container
515+
cat>$container_file<<EOF
516+
[Container]
517+
Image=$IMAGE
518+
Pod=test-pod
519+
Exec=sh -c "echo STARTED CONTAINER IN POD; trap 'exit' SIGTERM; while :; do sleep 0.1; done"
520+
EOF
521+
# Create a standalone container (no pod)
522+
local standalone_file=$PODMAN_TMPDIR/standalone.container
523+
cat>$standalone_file<<EOF
524+
[Container]
525+
Image=$IMAGE
526+
Exec=sh -c "echo STARTED STANDALONE; trap 'exit' SIGTERM; while :; do sleep 0.1; done"
527+
EOF
528+
# Install all quadlets
529+
run_podman quadlet install$pod_file$container_file$standalone_file
530+
531+
# Test that Pod field appears in custom format
532+
run_podman quadlet list --format'{{.Name}} {{.Pod}}'
533+
assert"$output" =~"pod-member.container test-pod""container in pod should show pod name"
534+
assert"$output" =~$'standalone.container[[:space:]]*$'"standalone container should have empty pod field"
535+
assert"$output" =~$'test-pod.pod[[:space:]]*$'"pod itself should have empty pod field"
536+
537+
# Test that Pod field works in JSON output
538+
run_podman quadlet list --format json
539+
assert"$output" =~'"Name".*"pod-member.container"'"JSON should contain pod-member"
540+
assert"$output" =~'"Pod".*"test-pod"'"JSON should show Pod field with value"
541+
542+
# Clean up
543+
run_podman quadlet rm test-pod.pod pod-member.container standalone.container
544+
}
545+
507546
# vim: filetype=sh

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp