Skip to content

Commit e636ed2

Browse files
committed
cli/command/stack: deprecate RunList, RunServices
Functions and types in this package were exported as part of the "compose on kubernetes" feature, which was deprecated and removed. These functions are meant for internal use, and will be removed in the next release. Signed-off-by: Sebastiaan van Stijn <github@gone.nl> (cherry picked from commit d16c560) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 19b7dfa commit e636ed2

File tree

2 files changed

+33
-14
lines changed

2 files changed

+33
-14
lines changed

cli/command/stack/list.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,18 @@ import (
1616
"github.com/spf13/cobra"
1717
)
1818

19+
type listOptions = options.List
20+
1921
func newListCommand(dockerCli command.Cli) *cobra.Command {
20-
opts := options.List{}
22+
opts := listOptions{}
2123

2224
cmd := &cobra.Command{
2325
Use: "ls [OPTIONS]",
2426
Aliases: []string{"list"},
2527
Short: "List stacks",
2628
Args: cli.NoArgs,
2729
RunE: func(cmd *cobra.Command, args []string) error {
28-
return RunList(cmd.Context(), dockerCli, opts)
30+
return runList(cmd.Context(), dockerCli, opts)
2931
},
3032
ValidArgsFunction: completion.NoComplete,
3133
}
@@ -36,17 +38,24 @@ func newListCommand(dockerCli command.Cli) *cobra.Command {
3638
}
3739

3840
// RunList performs a stack list against the specified swarm cluster
39-
func RunList(ctx context.Context, dockerCli command.Cli, opts options.List) error {
40-
ss, err := swarm.GetStacks(ctx, dockerCli.Client())
41+
//
42+
// Deprecated: this function was for internal use and will be removed in the next release.
43+
func RunList(ctx context.Context, dockerCLI command.Cli, opts options.List) error {
44+
return runList(ctx, dockerCLI, opts)
45+
}
46+
47+
// runList performs a stack list against the specified swarm cluster
48+
func runList(ctx context.Context, dockerCLI command.Cli, opts listOptions) error {
49+
ss, err := swarm.GetStacks(ctx, dockerCLI.Client())
4150
if err != nil {
4251
return err
4352
}
4453
stacks := make([]*formatter.Stack, 0, len(ss))
4554
stacks = append(stacks, ss...)
46-
return format(dockerCli.Out(), opts, stacks)
55+
return format(dockerCLI.Out(), opts, stacks)
4756
}
4857

49-
func format(out io.Writer, opts options.List, stacks []*formatter.Stack) error {
58+
func format(out io.Writer, opts listOptions, stacks []*formatter.Stack) error {
5059
fmt := formatter.Format(opts.Format)
5160
if fmt == "" || fmt == formatter.TableFormatKey {
5261
fmt = formatter.SwarmStackTableFormat

cli/command/stack/services.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)