Skip to content

Commit 733762a

Browse files
BenehikothaJeztah
authored andcommitted
Unexport swarm commands
This patch deprecates exported swarm commands and moves the implementation details to an unexported function. Commands that are affected include: - swarm.NewSwarmCommand Signed-off-by: Alano Terblanche <[email protected]> (cherry picked from commit bf39340) Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 4686287 commit 733762a

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

cli/command/commands/commands.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ func AddCommands(cmd *cobra.Command, dockerCli command.Cli) {
8989
service.NewServiceCommand(dockerCli),
9090
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
9191
stack.NewStackCommand(dockerCli),
92+
//nolint:staticcheck // TODO: Remove when migration to cli/internal/commands.Register is complete. (see #6283)
9293
swarm.NewSwarmCommand(dockerCli),
9394

9495
// legacy commands may be hidden

cli/command/swarm/cmd.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,33 @@ import (
88
)
99

1010
// NewSwarmCommand returns a cobra command for `swarm` subcommands
11-
func NewSwarmCommand(dockerCli command.Cli) *cobra.Command {
11+
//
12+
// Deprecated: Do not import commands directly. They will be removed in a future release.
13+
func NewSwarmCommand(dockerCLI command.Cli) *cobra.Command {
14+
return newSwarmCommand(dockerCLI)
15+
}
16+
17+
// newSwarmCommand returns a cobra command for `swarm` subcommands
18+
func newSwarmCommand(dockerCLI command.Cli) *cobra.Command {
1219
cmd := &cobra.Command{
1320
Use: "swarm",
1421
Short: "Manage Swarm",
1522
Args: cli.NoArgs,
16-
RunE: command.ShowHelp(dockerCli.Err()),
23+
RunE: command.ShowHelp(dockerCLI.Err()),
1724
Annotations: map[string]string{
1825
"version": "1.24",
1926
"swarm": "", // swarm command itself does not require swarm to be enabled (so swarm init and join is always available on API 1.24 and up)
2027
},
2128
}
2229
cmd.AddCommand(
23-
newInitCommand(dockerCli),
24-
newJoinCommand(dockerCli),
25-
newJoinTokenCommand(dockerCli),
26-
newUnlockKeyCommand(dockerCli),
27-
newUpdateCommand(dockerCli),
28-
newLeaveCommand(dockerCli),
29-
newUnlockCommand(dockerCli),
30-
newCACommand(dockerCli),
30+
newInitCommand(dockerCLI),
31+
newJoinCommand(dockerCLI),
32+
newJoinTokenCommand(dockerCLI),
33+
newUnlockKeyCommand(dockerCLI),
34+
newUpdateCommand(dockerCLI),
35+
newLeaveCommand(dockerCLI),
36+
newUnlockCommand(dockerCLI),
37+
newCACommand(dockerCLI),
3138
)
3239
return cmd
3340
}

0 commit comments

Comments
 (0)