summaryrefslogtreecommitdiff
path: root/pkg/trust
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2022-08-24 22:56:14 +0200
committerMiloslav Trmač <mitr@redhat.com>2022-08-25 01:50:43 +0200
commit4b2bd1036b4952a35a526202c8965cd3b32162ad (patch)
tree88857bd8d4022e5bf5f42c9ad11243c29e262dbf /pkg/trust
parent35fa8c16a2e921ac7c45d6df3fa09a0ec6fdbbdd (diff)
downloadpodman-4b2bd1036b4952a35a526202c8965cd3b32162ad.tar.gz
podman-4b2bd1036b4952a35a526202c8965cd3b32162ad.tar.bz2
podman-4b2bd1036b4952a35a526202c8965cd3b32162ad.zip
Make the output of (podman image trust show) deterministic
Sort map keys instead of iterating in the Go-imposed random order. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Diffstat (limited to 'pkg/trust')
-rw-r--r--pkg/trust/trust.go19
1 files changed, 17 insertions, 2 deletions
diff --git a/pkg/trust/trust.go b/pkg/trust/trust.go
index 606e4ed93..e93b4cd9d 100644
--- a/pkg/trust/trust.go
+++ b/pkg/trust/trust.go
@@ -2,6 +2,7 @@ package trust
import (
"fmt"
+ "sort"
"strings"
)
@@ -46,12 +47,26 @@ func getPolicyShowOutput(policyContentStruct policyContent, systemRegistriesDirP
}
output = append(output, &defaultPolicyStruct)
}
- for transport, transval := range policyContentStruct.Transports {
+ // FIXME: This should use x/exp/maps.Keys after we update to Go 1.18.
+ transports := []string{}
+ for t := range policyContentStruct.Transports {
+ transports = append(transports, t)
+ }
+ sort.Strings(transports)
+ for _, transport := range transports {
+ transval := policyContentStruct.Transports[transport]
if transport == "docker" {
transport = "repository"
}
- for repo, repoval := range transval {
+ // FIXME: This should use x/exp/maps.Keys after we update to Go 1.18.
+ scopes := []string{}
+ for s := range transval {
+ scopes = append(scopes, s)
+ }
+ sort.Strings(scopes)
+ for _, repo := range scopes {
+ repoval := transval[repo]
tempTrustShowOutput := Policy{
Name: repo,
RepoName: repo,