This patch removes the explicit `commands.AddCommands` function and instead relies upon the `internal/commands` package which registers each CLI command using `init()` instead. Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package swarm
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/docker/cli/cli"
|
|
"github.com/docker/cli/cli/command"
|
|
"github.com/docker/cli/internal/commands"
|
|
)
|
|
|
|
func init() {
|
|
commands.Register(newSwarmCommand)
|
|
}
|
|
|
|
// NewSwarmCommand returns a cobra command for `swarm` subcommands
|
|
//
|
|
// Deprecated: Do not import commands directly. They will be removed in a future release.
|
|
func NewSwarmCommand(dockerCLI command.Cli) *cobra.Command {
|
|
return newSwarmCommand(dockerCLI)
|
|
}
|
|
|
|
// newSwarmCommand returns a cobra command for `swarm` subcommands
|
|
func newSwarmCommand(dockerCLI command.Cli) *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "swarm",
|
|
Short: "Manage Swarm",
|
|
Args: cli.NoArgs,
|
|
RunE: command.ShowHelp(dockerCLI.Err()),
|
|
Annotations: map[string]string{
|
|
"version": "1.24",
|
|
"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)
|
|
},
|
|
}
|
|
cmd.AddCommand(
|
|
newInitCommand(dockerCLI),
|
|
newJoinCommand(dockerCLI),
|
|
newJoinTokenCommand(dockerCLI),
|
|
newUnlockKeyCommand(dockerCLI),
|
|
newUpdateCommand(dockerCLI),
|
|
newLeaveCommand(dockerCLI),
|
|
newUnlockCommand(dockerCLI),
|
|
newCACommand(dockerCLI),
|
|
)
|
|
return cmd
|
|
}
|