@@ -18,8 +18,11 @@ import (
1818 "github.com/spf13/cobra"
1919)
2020
21- func newServicesCommand (dockerCli command.Cli ) * cobra.Command {
22- opts := options.Services {Filter : cliopts .NewFilterOpt ()}
21+ // servicesOptions holds docker stack services options
22+ type servicesOptions = options.Services
23+
24+ func newServicesCommand (dockerCLI command.Cli ) * cobra.Command {
25+ opts := servicesOptions {Filter : cliopts .NewFilterOpt ()}
2326
2427 cmd := & cobra.Command {
2528 Use : "services [OPTIONS] STACK" ,
@@ -30,10 +33,10 @@ func newServicesCommand(dockerCli command.Cli) *cobra.Command {
3033 if err := validateStackName (opts .Namespace ); err != nil {
3134 return err
3235 }
33- return RunServices (cmd .Context (), dockerCli , opts )
36+ return runServices (cmd .Context (), dockerCLI , opts )
3437 },
3538 ValidArgsFunction : func (cmd * cobra.Command , args []string , toComplete string ) ([]string , cobra.ShellCompDirective ) {
36- return completeNames (dockerCli )(cmd , args , toComplete )
39+ return completeNames (dockerCLI )(cmd , args , toComplete )
3740 },
3841 }
3942 flags := cmd .Flags ()
@@ -44,15 +47,22 @@ func newServicesCommand(dockerCli command.Cli) *cobra.Command {
4447}
4548
4649// RunServices performs a stack services against the specified swarm cluster
47- func RunServices (ctx context.Context , dockerCli command.Cli , opts options.Services ) error {
48- services , err := swarm .GetServices (ctx , dockerCli , opts )
50+ //
51+ // Deprecated: this function was for internal use and will be removed in the next release.
52+ func RunServices (ctx context.Context , dockerCLI command.Cli , opts options.Services ) error {
53+ return runServices (ctx , dockerCLI , opts )
54+ }
55+
56+ // runServices performs a stack services against the specified swarm cluster
57+ func runServices (ctx context.Context , dockerCLI command.Cli , opts servicesOptions ) error {
58+ services , err := swarm .GetServices (ctx , dockerCLI , opts )
4959 if err != nil {
5060 return err
5161 }
52- return formatWrite (dockerCli , services , opts )
62+ return formatWrite (dockerCLI , services , opts )
5363}
5464
55- func formatWrite (dockerCLI command.Cli , services []swarmtypes.Service , opts options. Services ) error {
65+ func formatWrite (dockerCLI command.Cli , services []swarmtypes.Service , opts servicesOptions ) error {
5666 // if no services in the stack, print message and exit 0
5767 if len (services ) == 0 {
5868 _ , _ = fmt .Fprintln (dockerCLI .Err (), "Nothing found in stack:" , opts .Namespace )
0 commit comments