Skip to content

Commit 4a2b024

Browse files
BenehikothaJeztah
authored andcommitted
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 <[email protected]> (cherry picked from commit 630fe43) Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 82de059 commit 4a2b024

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

cli/command/commands/commands.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ func AddCommands(cmd *cobra.Command, dockerCli command.Cli) {
8484
secret.NewSecretCommand(dockerCli),
8585
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
8686
service.NewServiceCommand(dockerCli),
87+
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
8788
stack.NewStackCommand(dockerCli),
8889
swarm.NewSwarmCommand(dockerCli),
8990

cli/command/stack/cmd.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,19 @@ import (
1111
)
1212

1313
// NewStackCommand returns a cobra command for `stack` subcommands
14-
func NewStackCommand(dockerCli command.Cli) *cobra.Command {
14+
//
15+
// Deprecated: Do not import commands directly. They will be removed in a future release.
16+
func NewStackCommand(dockerCLI command.Cli) *cobra.Command {
17+
return newStackCommand(dockerCLI)
18+
}
19+
20+
// newStackCommand returns a cobra command for `stack` subcommands
21+
func newStackCommand(dockerCLI command.Cli) *cobra.Command {
1522
cmd := &cobra.Command{
1623
Use: "stack [OPTIONS]",
1724
Short: "Manage Swarm stacks",
1825
Args: cli.NoArgs,
19-
RunE: command.ShowHelp(dockerCli.Err()),
26+
RunE: command.ShowHelp(dockerCLI.Err()),
2027
Annotations: map[string]string{
2128
"version": "1.25",
2229
"swarm": "manager",
@@ -25,18 +32,18 @@ func NewStackCommand(dockerCli command.Cli) *cobra.Command {
2532
defaultHelpFunc := cmd.HelpFunc()
2633
cmd.SetHelpFunc(func(c *cobra.Command, args []string) {
2734
if err := cmd.Root().PersistentPreRunE(c, args); err != nil {
28-
fmt.Fprintln(dockerCli.Err(), err)
35+
fmt.Fprintln(dockerCLI.Err(), err)
2936
return
3037
}
3138
defaultHelpFunc(c, args)
3239
})
3340
cmd.AddCommand(
34-
newDeployCommand(dockerCli),
35-
newListCommand(dockerCli),
36-
newPsCommand(dockerCli),
37-
newRemoveCommand(dockerCli),
38-
newServicesCommand(dockerCli),
39-
newConfigCommand(dockerCli),
41+
newDeployCommand(dockerCLI),
42+
newListCommand(dockerCLI),
43+
newPsCommand(dockerCLI),
44+
newRemoveCommand(dockerCLI),
45+
newServicesCommand(dockerCLI),
46+
newConfigCommand(dockerCLI),
4047
)
4148
flags := cmd.PersistentFlags()
4249
flags.String("orchestrator", "", "Orchestrator to use (swarm|all)")

0 commit comments

Comments
 (0)