From 34447852b5db40a40359d12e8e59b92d7881f7f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Szczekutowicz?= Date: Thu, 1 Aug 2019 21:52:18 +0200 Subject: [PATCH] Sort services from stack from swarm MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Paweł Szczekutowicz --- cli/command/stack/swarm/services.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cli/command/stack/swarm/services.go b/cli/command/stack/swarm/services.go index cd7208f8b7..15a48e7893 100644 --- a/cli/command/stack/swarm/services.go +++ b/cli/command/stack/swarm/services.go @@ -3,6 +3,7 @@ package swarm import ( "context" "fmt" + "sort" "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command/service" @@ -10,6 +11,7 @@ import ( "github.com/docker/cli/cli/command/stack/options" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" + "vbom.ml/util/sortorder" ) // RunServices is the swarm implementation of docker stack services @@ -29,6 +31,9 @@ func RunServices(dockerCli command.Cli, opts options.Services) error { return nil } + sort.Slice(services, func(i, j int) bool { + return sortorder.NaturalLess(services[i].Spec.Name, services[j].Spec.Name) + }) info := map[string]service.ListInfo{} if !opts.Quiet { taskFilter := filters.NewArgs()