diff --git a/libpod/pod_api.go b/libpod/pod_api.go index 6872db01c5..d8fd64ac48 100644 --- a/libpod/pod_api.go +++ b/libpod/pod_api.go @@ -6,6 +6,9 @@ import ( "context" "errors" "fmt" + "slices" + "sort" + "strings" "github.com/containers/podman/v6/libpod/define" "github.com/containers/podman/v6/libpod/events" @@ -620,6 +623,8 @@ func (p *Pod) Inspect() (*define.InspectPodData, error) { ctrStatuses[c.ID()] = c.state.State } } + slices.SortFunc(ctrs, func(a, b define.InspectPodContainerInfo) int { return strings.Compare(a.ID, b.ID) }) + podState, err := createPodStatusResults(ctrStatuses) if err != nil { return nil, err @@ -641,6 +646,7 @@ func (p *Pod) Inspect() (*define.InspectPodData, error) { sharesNS = append(sharesNS, nsStr) } } + sort.Strings(sharesNS) // Infra config contains detailed information on the pod's infra // container. diff --git a/test/system/200-pod.bats b/test/system/200-pod.bats index f59223cd25..c4bf92305f 100644 --- a/test/system/200-pod.bats +++ b/test/system/200-pod.bats @@ -807,4 +807,12 @@ function thingy_with_unique_id() { done } +@test "podman pod inspect ordering" { + local pod_name="p-$(safename)" + run_podman pod create $pod_name + + run_podman pod inspect --format '{{ .SharedNamespaces }}' $pod_name + assert "$output" == "[ipc net uts]" +} + # vim: filetype=sh