Sort services from stack from swarm

Signed-off-by: Paweł Szczekutowicz <pszczekutowicz@gmail.com>
This commit is contained in:
Paweł Szczekutowicz 2019-08-01 21:52:18 +02:00
parent e505a7c216
commit 34447852b5
1 changed files with 5 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package swarm
import ( import (
"context" "context"
"fmt" "fmt"
"sort"
"github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/command/service" "github.com/docker/cli/cli/command/service"
@ -10,6 +11,7 @@ import (
"github.com/docker/cli/cli/command/stack/options" "github.com/docker/cli/cli/command/stack/options"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/filters"
"vbom.ml/util/sortorder"
) )
// RunServices is the swarm implementation of docker stack services // RunServices is the swarm implementation of docker stack services
@ -29,6 +31,9 @@ func RunServices(dockerCli command.Cli, opts options.Services) error {
return nil 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{} info := map[string]service.ListInfo{}
if !opts.Quiet { if !opts.Quiet {
taskFilter := filters.NewArgs() taskFilter := filters.NewArgs()