2016-09-08 13:11:39 -04:00
|
|
|
package stack
|
|
|
|
|
|
|
|
import (
|
2018-04-25 08:24:46 -04:00
|
|
|
"fmt"
|
|
|
|
|
2017-04-17 18:07:56 -04:00
|
|
|
"github.com/docker/cli/cli"
|
|
|
|
"github.com/docker/cli/cli/command"
|
2016-09-08 13:11:39 -04:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2018-04-25 08:24:46 -04:00
|
|
|
var errUnsupportedAllOrchestrator = fmt.Errorf(`no orchestrator specified: use either "kubernetes" or "swarm"`)
|
|
|
|
|
2016-10-06 10:09:54 -04:00
|
|
|
// NewStackCommand returns a cobra command for `stack` subcommands
|
2017-10-11 12:18:27 -04:00
|
|
|
func NewStackCommand(dockerCli command.Cli) *cobra.Command {
|
2016-10-06 10:09:54 -04:00
|
|
|
cmd := &cobra.Command{
|
2018-01-11 17:42:50 -05:00
|
|
|
Use: "stack",
|
|
|
|
Short: "Manage Docker stacks",
|
|
|
|
Args: cli.NoArgs,
|
|
|
|
RunE: command.ShowHelp(dockerCli.Err()),
|
|
|
|
Annotations: map[string]string{
|
|
|
|
"kubernetes": "",
|
|
|
|
"swarm": "",
|
|
|
|
"version": "1.25",
|
|
|
|
},
|
2016-10-06 10:09:54 -04:00
|
|
|
}
|
2017-12-04 06:30:39 -05:00
|
|
|
cmd.AddCommand(
|
|
|
|
newDeployCommand(dockerCli),
|
|
|
|
newListCommand(dockerCli),
|
|
|
|
newPsCommand(dockerCli),
|
|
|
|
newRemoveCommand(dockerCli),
|
|
|
|
newServicesCommand(dockerCli),
|
|
|
|
)
|
|
|
|
flags := cmd.PersistentFlags()
|
|
|
|
flags.String("kubeconfig", "", "Kubernetes config file")
|
|
|
|
flags.SetAnnotation("kubeconfig", "kubernetes", nil)
|
2018-01-02 17:56:07 -05:00
|
|
|
flags.SetAnnotation("kubeconfig", "experimentalCLI", nil)
|
2016-10-06 10:09:54 -04:00
|
|
|
return cmd
|
2016-09-08 13:11:39 -04:00
|
|
|
}
|
|
|
|
|
2016-10-06 10:09:54 -04:00
|
|
|
// NewTopLevelDeployCommand returns a command for `docker deploy`
|
2017-05-03 17:58:52 -04:00
|
|
|
func NewTopLevelDeployCommand(dockerCli command.Cli) *cobra.Command {
|
2017-12-04 06:30:39 -05:00
|
|
|
cmd := newDeployCommand(dockerCli)
|
2016-10-06 10:09:54 -04:00
|
|
|
// Remove the aliases at the top level
|
|
|
|
cmd.Aliases = []string{}
|
2018-01-11 17:42:50 -05:00
|
|
|
cmd.Annotations = map[string]string{
|
|
|
|
"experimental": "",
|
|
|
|
"swarm": "",
|
|
|
|
"version": "1.25",
|
|
|
|
}
|
2016-10-06 10:09:54 -04:00
|
|
|
return cmd
|
2016-09-08 13:11:39 -04:00
|
|
|
}
|