diff --git a/cli/command/stack/deploy.go b/cli/command/stack/deploy.go index 1c9643e3ef..8b977ad0a1 100644 --- a/cli/command/stack/deploy.go +++ b/cli/command/stack/deploy.go @@ -28,7 +28,7 @@ func newDeployCommand(dockerCli command.Cli) *cobra.Command { if err != nil { return err } - return RunDeploy(dockerCli, cmd.Flags(), config, opts) + return swarm.RunDeploy(dockerCli, opts, config) }, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { return completeNames(dockerCli)(cmd, args, toComplete) @@ -47,7 +47,9 @@ func newDeployCommand(dockerCli command.Cli) *cobra.Command { return cmd } -// RunDeploy performs a stack deploy against the specified swarm cluster -func RunDeploy(dockerCli command.Cli, flags *pflag.FlagSet, config *composetypes.Config, opts options.Deploy) error { +// RunDeploy performs a stack deploy against the specified swarm cluster. +// +// Deprecated: use [swarm.RunDeploy] instead. +func RunDeploy(dockerCli command.Cli, _ *pflag.FlagSet, config *composetypes.Config, opts options.Deploy) error { return swarm.RunDeploy(dockerCli, opts, config) } diff --git a/cli/command/stack/list.go b/cli/command/stack/list.go index 40c1898cc6..fc5b03d651 100644 --- a/cli/command/stack/list.go +++ b/cli/command/stack/list.go @@ -23,7 +23,7 @@ func newListCommand(dockerCli command.Cli) *cobra.Command { Short: "List stacks", Args: cli.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { - return RunList(cmd, dockerCli, opts) + return RunList(dockerCli, opts) }, ValidArgsFunction: completion.NoComplete, } @@ -34,24 +34,24 @@ func newListCommand(dockerCli command.Cli) *cobra.Command { } // RunList performs a stack list against the specified swarm cluster -func RunList(cmd *cobra.Command, dockerCli command.Cli, opts options.List) error { - stacks := []*formatter.Stack{} +func RunList(dockerCli command.Cli, opts options.List) error { ss, err := swarm.GetStacks(dockerCli) if err != nil { return err } + stacks := make([]*formatter.Stack, 0, len(ss)) stacks = append(stacks, ss...) return format(dockerCli, opts, stacks) } func format(dockerCli command.Cli, opts options.List, stacks []*formatter.Stack) error { - format := formatter.Format(opts.Format) - if format == "" || format == formatter.TableFormatKey { - format = formatter.SwarmStackTableFormat + fmt := formatter.Format(opts.Format) + if fmt == "" || fmt == formatter.TableFormatKey { + fmt = formatter.SwarmStackTableFormat } stackCtx := formatter.Context{ Output: dockerCli.Out(), - Format: format, + Format: fmt, } sort.Slice(stacks, func(i, j int) bool { return sortorder.NaturalLess(stacks[i].Name, stacks[j].Name) || diff --git a/cli/command/stack/ps.go b/cli/command/stack/ps.go index 84c250ea91..f962b895a7 100644 --- a/cli/command/stack/ps.go +++ b/cli/command/stack/ps.go @@ -23,7 +23,7 @@ func newPsCommand(dockerCli command.Cli) *cobra.Command { if err := validateStackName(opts.Namespace); err != nil { return err } - return RunPs(dockerCli, cmd.Flags(), opts) + return swarm.RunPS(dockerCli, opts) }, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { return completeNames(dockerCli)(cmd, args, toComplete) @@ -38,7 +38,9 @@ func newPsCommand(dockerCli command.Cli) *cobra.Command { return cmd } -// RunPs performs a stack ps against the specified swarm cluster -func RunPs(dockerCli command.Cli, flags *pflag.FlagSet, opts options.PS) error { +// RunPs performs a stack ps against the specified swarm cluster. +// +// Deprecated: use [swarm.RunPS] instead. +func RunPs(dockerCli command.Cli, _ *pflag.FlagSet, opts options.PS) error { return swarm.RunPS(dockerCli, opts) } diff --git a/cli/command/stack/remove.go b/cli/command/stack/remove.go index 9e55e65a7e..34827666d0 100644 --- a/cli/command/stack/remove.go +++ b/cli/command/stack/remove.go @@ -22,7 +22,7 @@ func newRemoveCommand(dockerCli command.Cli) *cobra.Command { if err := validateStackNames(opts.Namespaces); err != nil { return err } - return RunRemove(dockerCli, cmd.Flags(), opts) + return swarm.RunRemove(dockerCli, opts) }, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { return completeNames(dockerCli)(cmd, args, toComplete) @@ -31,7 +31,9 @@ func newRemoveCommand(dockerCli command.Cli) *cobra.Command { return cmd } -// RunRemove performs a stack remove against the specified swarm cluster -func RunRemove(dockerCli command.Cli, flags *pflag.FlagSet, opts options.Remove) error { +// RunRemove performs a stack remove against the specified swarm cluster. +// +// Deprecated: use [swarm.RunRemove] instead. +func RunRemove(dockerCli command.Cli, _ *pflag.FlagSet, opts options.Remove) error { return swarm.RunRemove(dockerCli, opts) } diff --git a/cli/command/stack/services.go b/cli/command/stack/services.go index cc0bdc5e2b..ef1947614a 100644 --- a/cli/command/stack/services.go +++ b/cli/command/stack/services.go @@ -30,7 +30,7 @@ func newServicesCommand(dockerCli command.Cli) *cobra.Command { if err := validateStackName(opts.Namespace); err != nil { return err } - return RunServices(dockerCli, cmd.Flags(), opts) + return RunServices(dockerCli, opts) }, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { return completeNames(dockerCli)(cmd, args, toComplete) @@ -44,16 +44,18 @@ func newServicesCommand(dockerCli command.Cli) *cobra.Command { } // RunServices performs a stack services against the specified swarm cluster -func RunServices(dockerCli command.Cli, flags *pflag.FlagSet, opts options.Services) error { - services, err := GetServices(dockerCli, flags, opts) +func RunServices(dockerCli command.Cli, opts options.Services) error { + services, err := swarm.GetServices(dockerCli, opts) if err != nil { return err } return formatWrite(dockerCli, services, opts) } -// GetServices returns the services for the specified swarm cluster -func GetServices(dockerCli command.Cli, flags *pflag.FlagSet, opts options.Services) ([]swarmtypes.Service, error) { +// GetServices returns the services for the specified swarm cluster. +// +// Deprecated: use [swarm.GetServices] instead. +func GetServices(dockerCli command.Cli, _ *pflag.FlagSet, opts options.Services) ([]swarmtypes.Service, error) { return swarm.GetServices(dockerCli, opts) }