@@ -2,13 +2,11 @@ package stack
22
33import (
44 "context"
5- "io"
65 "sort"
76
87 "github.com/docker/cli/cli"
98 "github.com/docker/cli/cli/command"
10- "github.com/docker/cli/cli/command/stack/formatter"
11- "github.com/docker/cli/cli/command/stack/swarm"
9+ "github.com/docker/cli/cli/command/formatter"
1210 flagsHelper "github.com/docker/cli/cli/flags"
1311 "github.com/fvbommel/sortorder"
1412 "github.com/spf13/cobra"
@@ -40,24 +38,21 @@ func newListCommand(dockerCLI command.Cli) *cobra.Command {
4038
4139// runList performs a stack list against the specified swarm cluster
4240func runList (ctx context.Context , dockerCLI command.Cli , opts listOptions ) error {
43- stacks , err := swarm . GetStacks (ctx , dockerCLI .Client ())
41+ stacks , err := getStacks (ctx , dockerCLI .Client ())
4442 if err != nil {
4543 return err
4644 }
47- return format (dockerCLI .Out (), opts , stacks )
48- }
4945
50- func format (out io.Writer , opts listOptions , stacks []formatter.Stack ) error {
51- fmt := formatter .Format (opts .format )
52- if fmt == "" || fmt == formatter .TableFormatKey {
53- fmt = formatter .SwarmStackTableFormat
46+ format := formatter .Format (opts .format )
47+ if format == "" || format == formatter .TableFormatKey {
48+ format = stackTableFormat
5449 }
5550 stackCtx := formatter.Context {
56- Output : out ,
57- Format : fmt ,
51+ Output : dockerCLI . Out () ,
52+ Format : format ,
5853 }
5954 sort .Slice (stacks , func (i , j int ) bool {
6055 return sortorder .NaturalLess (stacks [i ].Name , stacks [j ].Name )
6156 })
62- return formatter . StackWrite (stackCtx , stacks )
57+ return stackWrite (stackCtx , stacks )
6358}
0 commit comments