summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2021-12-13 22:20:53 +0100
committerPaul Holzinger <pholzing@redhat.com>2021-12-14 13:52:38 +0100
commit5f1f62f0bb7465cf935ea4353cf5afaa03f633af (patch)
tree0c4964479c27158c225a6ccb93c3a9beee586ec6 /cmd/podman
parent4543fd463e3d02aea42f1a5b6ed0d2ed190de655 (diff)
downloadpodman-5f1f62f0bb7465cf935ea4353cf5afaa03f633af.tar.gz
podman-5f1f62f0bb7465cf935ea4353cf5afaa03f633af.tar.bz2
podman-5f1f62f0bb7465cf935ea4353cf5afaa03f633af.zip
network ls: show networks in deterministic order
The new network backend stores the networks in a map so the returned order is not deterministic. Lets sort the network names alphabetically to ensure a deterministic order. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/networks/list.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/cmd/podman/networks/list.go b/cmd/podman/networks/list.go
index 6f1a7742a..7ce566225 100644
--- a/cmd/podman/networks/list.go
+++ b/cmd/podman/networks/list.go
@@ -3,6 +3,7 @@ package network
import (
"fmt"
"os"
+ "sort"
"strings"
"github.com/containers/common/pkg/completion"
@@ -73,6 +74,11 @@ func networkList(cmd *cobra.Command, args []string) error {
return err
}
+ // sort the networks to make sure the order is deterministic
+ sort.Slice(responses, func(i, j int) bool {
+ return responses[i].Name < responses[j].Name
+ })
+
switch {
// quiet means we only print the network names
case networkListOptions.Quiet: