Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Commit 970f0ee

Browse files
Merge pull request #2028 from pszczekutowicz/master
Sort list of services from swarm stacks using natural sorting Upstream-commit: 7aa764bba9f328994a781c81deec41cb5c5b391b Component: cli
2 parents 5a1418a + c58e061 commit 970f0ee

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

components/cli/cli/command/stack/swarm/services.go

+5
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ package swarm
33
import (
44
"context"
55
"fmt"
6+
"sort"
67

78
"github.com/docker/cli/cli/command"
89
"github.com/docker/cli/cli/command/service"
910
"github.com/docker/cli/cli/command/stack/formatter"
1011
"github.com/docker/cli/cli/command/stack/options"
1112
"github.com/docker/docker/api/types"
1213
"github.com/docker/docker/api/types/filters"
14+
"vbom.ml/util/sortorder"
1315
)
1416

1517
// RunServices is the swarm implementation of docker stack services
@@ -29,6 +31,9 @@ func RunServices(dockerCli command.Cli, opts options.Services) error {
2931
return nil
3032
}
3133

34+
sort.Slice(services, func(i, j int) bool {
35+
return sortorder.NaturalLess(services[i].Spec.Name, services[j].Spec.Name)
36+
})
3237
info := map[string]service.ListInfo{}
3338
if !opts.Quiet {
3439
taskFilter := filters.NewArgs()

0 commit comments

Comments
 (0)