Make system connection ls deterministic

Sort system connection ls by name, making the output deterministic. Previously, we were just iterating through a map, which caused CI flakes.

Signed-off-by: Ashley Cui <acui@redhat.com>
This commit is contained in:
Ashley Cui
2021-06-29 14:56:15 -04:00
parent 599b7d746a
commit 3e8c0e00de

View File

@ -3,6 +3,7 @@ package connection
import (
"fmt"
"os"
"sort"
"github.com/containers/common/pkg/completion"
"github.com/containers/common/pkg/config"
@ -77,6 +78,10 @@ func list(cmd *cobra.Command, _ []string) error {
rows = append(rows, r)
}
sort.Slice(rows, func(i, j int) bool {
return rows[i].Name < rows[j].Name
})
format := "{{.Name}}\t{{.Identity}}\t{{.URI}}\n"
switch {
case report.IsJSON(cmd.Flag("format").Value.String()):