diff --git a/libpod/pod_api.go b/libpod/pod_api.go index adaff0a322..cc5e8eed54 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/v5/libpod/define" "github.com/containers/podman/v5/libpod/events" @@ -633,6 +636,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 @@ -654,6 +659,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 1887e68ec4..db583e73c0 100644 --- a/test/system/200-pod.bats +++ b/test/system/200-pod.bats @@ -809,4 +809,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