diff options
author | Miloslav Trmač <mitr@redhat.com> | 2022-08-24 22:56:14 +0200 |
---|---|---|
committer | Miloslav Trmač <mitr@redhat.com> | 2022-08-29 17:55:38 +0200 |
commit | 721de77c40783c90954ad46c6fd3b1443b770052 (patch) | |
tree | bde76862e93fbc78602e77b4e75b9db6a49a7eb1 | |
parent | 333749b80471076d7accfb6e777d4d9b06734f15 (diff) | |
download | podman-721de77c40783c90954ad46c6fd3b1443b770052.tar.gz podman-721de77c40783c90954ad46c6fd3b1443b770052.tar.bz2 podman-721de77c40783c90954ad46c6fd3b1443b770052.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>
-rw-r--r-- | pkg/trust/trust.go | 19 |
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, |