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 d16c560664)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -16,8 +16,10 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
type listOptions = options.List
|
||||
|
||||
func newListCommand(dockerCli command.Cli) *cobra.Command {
|
||||
opts := options.List{}
|
||||
opts := listOptions{}
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "ls [OPTIONS]",
|
||||
@@ -25,7 +27,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.Context(), dockerCli, opts)
|
||||
return runList(cmd.Context(), dockerCli, opts)
|
||||
},
|
||||
ValidArgsFunction: completion.NoComplete,
|
||||
}
|
||||
@@ -36,17 +38,24 @@ func newListCommand(dockerCli command.Cli) *cobra.Command {
|
||||
}
|
||||
|
||||
// RunList performs a stack list against the specified swarm cluster
|
||||
func RunList(ctx context.Context, dockerCli command.Cli, opts options.List) error {
|
||||
ss, err := swarm.GetStacks(ctx, dockerCli.Client())
|
||||
//
|
||||
// Deprecated: this function was for internal use and will be removed in the next release.
|
||||
func RunList(ctx context.Context, dockerCLI command.Cli, opts options.List) error {
|
||||
return runList(ctx, dockerCLI, opts)
|
||||
}
|
||||
|
||||
// runList performs a stack list against the specified swarm cluster
|
||||
func runList(ctx context.Context, dockerCLI command.Cli, opts listOptions) error {
|
||||
ss, err := swarm.GetStacks(ctx, dockerCLI.Client())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
stacks := make([]*formatter.Stack, 0, len(ss))
|
||||
stacks = append(stacks, ss...)
|
||||
return format(dockerCli.Out(), opts, stacks)
|
||||
return format(dockerCLI.Out(), opts, stacks)
|
||||
}
|
||||
|
||||
func format(out io.Writer, opts options.List, stacks []*formatter.Stack) error {
|
||||
func format(out io.Writer, opts listOptions, stacks []*formatter.Stack) error {
|
||||
fmt := formatter.Format(opts.Format)
|
||||
if fmt == "" || fmt == formatter.TableFormatKey {
|
||||
fmt = formatter.SwarmStackTableFormat
|
||||
|
||||
@@ -18,8 +18,11 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func newServicesCommand(dockerCli command.Cli) *cobra.Command {
|
||||
opts := options.Services{Filter: cliopts.NewFilterOpt()}
|
||||
// servicesOptions holds docker stack services options
|
||||
type servicesOptions = options.Services
|
||||
|
||||
func newServicesCommand(dockerCLI command.Cli) *cobra.Command {
|
||||
opts := servicesOptions{Filter: cliopts.NewFilterOpt()}
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "services [OPTIONS] STACK",
|
||||
@@ -30,10 +33,10 @@ func newServicesCommand(dockerCli command.Cli) *cobra.Command {
|
||||
if err := validateStackName(opts.Namespace); err != nil {
|
||||
return err
|
||||
}
|
||||
return RunServices(cmd.Context(), dockerCli, opts)
|
||||
return runServices(cmd.Context(), dockerCLI, opts)
|
||||
},
|
||||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||
return completeNames(dockerCli)(cmd, args, toComplete)
|
||||
return completeNames(dockerCLI)(cmd, args, toComplete)
|
||||
},
|
||||
}
|
||||
flags := cmd.Flags()
|
||||
@@ -44,15 +47,22 @@ func newServicesCommand(dockerCli command.Cli) *cobra.Command {
|
||||
}
|
||||
|
||||
// RunServices performs a stack services against the specified swarm cluster
|
||||
func RunServices(ctx context.Context, dockerCli command.Cli, opts options.Services) error {
|
||||
services, err := swarm.GetServices(ctx, dockerCli, opts)
|
||||
//
|
||||
// Deprecated: this function was for internal use and will be removed in the next release.
|
||||
func RunServices(ctx context.Context, dockerCLI command.Cli, opts options.Services) error {
|
||||
return runServices(ctx, dockerCLI, opts)
|
||||
}
|
||||
|
||||
// runServices performs a stack services against the specified swarm cluster
|
||||
func runServices(ctx context.Context, dockerCLI command.Cli, opts servicesOptions) error {
|
||||
services, err := swarm.GetServices(ctx, dockerCLI, opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return formatWrite(dockerCli, services, opts)
|
||||
return formatWrite(dockerCLI, services, opts)
|
||||
}
|
||||
|
||||
func formatWrite(dockerCLI command.Cli, services []swarmtypes.Service, opts options.Services) error {
|
||||
func formatWrite(dockerCLI command.Cli, services []swarmtypes.Service, opts servicesOptions) error {
|
||||
// if no services in the stack, print message and exit 0
|
||||
if len(services) == 0 {
|
||||
_, _ = fmt.Fprintln(dockerCLI.Err(), "Nothing found in stack:", opts.Namespace)
|
||||
|
||||
Reference in New Issue
Block a user