mirror of
https://github.com/docker/cli.git
synced 2026-09-26 17:30:51 -04:00
cmd/docker-trust: update naturalsort sorting with slices
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -5,7 +5,6 @@ import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/docker/cli/cli/command"
|
||||
@@ -163,8 +162,8 @@ func matchReleasedSignatures(allTargets []client.TargetSignedStruct) []trustTagR
|
||||
for targetKey, signers := range releasedTargetRows {
|
||||
signatureRows = append(signatureRows, trustTagRow{targetKey, signers})
|
||||
}
|
||||
sort.Slice(signatureRows, func(i, j int) bool {
|
||||
return sortorder.NaturalLess(signatureRows[i].SignedTag, signatureRows[j].SignedTag)
|
||||
slices.SortFunc(signatureRows, func(a, b trustTagRow) int {
|
||||
return sortorder.NaturalCompare(a.SignedTag, b.SignedTag)
|
||||
})
|
||||
return signatureRows
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"slices"
|
||||
"sort"
|
||||
|
||||
"github.com/docker/cli/cli/command"
|
||||
"github.com/docker/cli/cli/command/formatter"
|
||||
@@ -85,15 +84,15 @@ func printSignerInfo(out io.Writer, roleToKeyIDs map[string][]string) error {
|
||||
Format: defaultSignerInfoTableFormat,
|
||||
Trunc: true,
|
||||
}
|
||||
formattedSignerInfo := []signerInfo{}
|
||||
formattedSignerInfo := make([]signerInfo, 0, len(roleToKeyIDs))
|
||||
for name, keyIDs := range roleToKeyIDs {
|
||||
formattedSignerInfo = append(formattedSignerInfo, signerInfo{
|
||||
Name: name,
|
||||
Keys: keyIDs,
|
||||
})
|
||||
}
|
||||
sort.Slice(formattedSignerInfo, func(i, j int) bool {
|
||||
return sortorder.NaturalLess(formattedSignerInfo[i].Name, formattedSignerInfo[j].Name)
|
||||
slices.SortFunc(formattedSignerInfo, func(a, b signerInfo) int {
|
||||
return sortorder.NaturalCompare(a.Name, b.Name)
|
||||
})
|
||||
return signerInfoWrite(signerInfoCtx, formattedSignerInfo)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user