forked from TrueCloudLab/frostfs-node
[#333] Sort containers by ID
Signed-off-by: Ekaterina Lebedeva <ekaterina.lebedeva@yadro.com>
This commit is contained in:
parent
c14c9a023c
commit
b8c3c2486d
2 changed files with 11 additions and 1 deletions
|
@ -71,6 +71,16 @@ func ListContainers(ctx context.Context, prm ListContainersPrm) (res ListContain
|
|||
return
|
||||
}
|
||||
|
||||
// SortedIDList returns sorted list of identifiers of user's containers.
|
||||
func (x ListContainersRes) SortedIDList() []cid.ID {
|
||||
list := x.cliRes.Containers()
|
||||
sort.Slice(list, func(i, j int) bool {
|
||||
lhs, rhs := list[i].EncodeToString(), list[j].EncodeToString()
|
||||
return strings.Compare(lhs, rhs) < 0
|
||||
})
|
||||
return list
|
||||
}
|
||||
|
||||
// PutContainerPrm groups parameters of PutContainer operation.
|
||||
type PutContainerPrm struct {
|
||||
Client *client.Client
|
||||
|
|
|
@ -56,7 +56,7 @@ var listContainersCmd = &cobra.Command{
|
|||
Client: cli,
|
||||
}
|
||||
|
||||
containerIDs := res.IDList()
|
||||
containerIDs := res.SortedIDList()
|
||||
for _, cnrID := range containerIDs {
|
||||
if flagVarListName == "" && !flagVarListPrintAttr {
|
||||
cmd.Println(cnrID.String())
|
||||
|
|
Loading…
Reference in a new issue