mirror of
https://github.com/containers/podman.git
synced 2025-05-20 08:36:23 +08:00
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>
This commit is contained in:
@ -2,6 +2,7 @@ package trust
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -46,12 +47,26 @@ func getPolicyShowOutput(policyContentStruct policyContent, systemRegistriesDirP
|
|||||||
}
|
}
|
||||||
output = append(output, &defaultPolicyStruct)
|
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" {
|
if transport == "docker" {
|
||||||
transport = "repository"
|
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{
|
tempTrustShowOutput := Policy{
|
||||||
Name: repo,
|
Name: repo,
|
||||||
RepoName: repo,
|
RepoName: repo,
|
||||||
|
Reference in New Issue
Block a user