Make `ps` order predictable

so one can run `watch docker ecs compose ps`

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2020-05-29 15:13:16 +02:00
parent 5080a83242
commit ff88290302
No known key found for this signature in database
GPG Key ID: 9858809D6F8F6E7E
1 changed files with 5 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"os"
"sort"
"strings"
"text/tabwriter"
@ -43,6 +44,10 @@ func (c *client) ComposePs(ctx context.Context, project *compose.Project) error
return err
}
sort.Slice(tasks, func(i, j int) bool {
return strings.Compare(tasks[i].Service, tasks[j].Service) < 0
})
for _, t := range tasks {
ports := []string{}
s, err := project.GetService(t.Service)