1
0
mirror of https://github.com/docker/cli.git synced 2026-01-13 18:22:35 +03:00

Unexport stack commands

This patch deprecates exported stack commands and moves the implementation
details to an unexported function.

Commands that are affected include:

- stack.NewStackCommand

Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
This commit is contained in:
Alano Terblanche
2025-08-20 13:27:11 +02:00
parent 89316e18fc
commit 630fe430ff
2 changed files with 17 additions and 9 deletions

View File

@@ -83,6 +83,7 @@ func AddCommands(cmd *cobra.Command, dockerCli command.Cli) {
secret.NewSecretCommand(dockerCli),
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
service.NewServiceCommand(dockerCli),
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
stack.NewStackCommand(dockerCli),
swarm.NewSwarmCommand(dockerCli),

View File

@@ -11,12 +11,19 @@ import (
)
// NewStackCommand returns a cobra command for `stack` subcommands
func NewStackCommand(dockerCli command.Cli) *cobra.Command {
//
// Deprecated: Do not import commands directly. They will be removed in a future release.
func NewStackCommand(dockerCLI command.Cli) *cobra.Command {
return newStackCommand(dockerCLI)
}
// newStackCommand returns a cobra command for `stack` subcommands
func newStackCommand(dockerCLI command.Cli) *cobra.Command {
cmd := &cobra.Command{
Use: "stack [OPTIONS]",
Short: "Manage Swarm stacks",
Args: cli.NoArgs,
RunE: command.ShowHelp(dockerCli.Err()),
RunE: command.ShowHelp(dockerCLI.Err()),
Annotations: map[string]string{
"version": "1.25",
"swarm": "manager",
@@ -25,18 +32,18 @@ func NewStackCommand(dockerCli command.Cli) *cobra.Command {
defaultHelpFunc := cmd.HelpFunc()
cmd.SetHelpFunc(func(c *cobra.Command, args []string) {
if err := cmd.Root().PersistentPreRunE(c, args); err != nil {
fmt.Fprintln(dockerCli.Err(), err)
fmt.Fprintln(dockerCLI.Err(), err)
return
}
defaultHelpFunc(c, args)
})
cmd.AddCommand(
newDeployCommand(dockerCli),
newListCommand(dockerCli),
newPsCommand(dockerCli),
newRemoveCommand(dockerCli),
newServicesCommand(dockerCli),
newConfigCommand(dockerCli),
newDeployCommand(dockerCLI),
newListCommand(dockerCLI),
newPsCommand(dockerCLI),
newRemoveCommand(dockerCLI),
newServicesCommand(dockerCLI),
newConfigCommand(dockerCLI),
)
flags := cmd.PersistentFlags()
flags.String("orchestrator", "", "Orchestrator to use (swarm|all)")