2017-12-04 06:30:39 -05:00
|
|
|
package stack
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/docker/cli/cli"
|
|
|
|
"github.com/docker/cli/cli/command"
|
|
|
|
"github.com/docker/cli/cli/command/stack/kubernetes"
|
|
|
|
"github.com/docker/cli/cli/command/stack/options"
|
|
|
|
"github.com/docker/cli/cli/command/stack/swarm"
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
|
|
|
func newRemoveCommand(dockerCli command.Cli) *cobra.Command {
|
|
|
|
var opts options.Remove
|
|
|
|
|
|
|
|
cmd := &cobra.Command{
|
|
|
|
Use: "rm STACK [STACK...]",
|
|
|
|
Aliases: []string{"remove", "down"},
|
|
|
|
Short: "Remove one or more stacks",
|
|
|
|
Args: cli.RequiresMinArgs(1),
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
opts.Namespaces = args
|
2018-01-02 17:56:07 -05:00
|
|
|
if dockerCli.ClientInfo().HasKubernetes() {
|
2018-02-22 08:55:42 -05:00
|
|
|
kli, err := kubernetes.WrapCli(dockerCli, kubernetes.NewOptions(cmd.Flags()))
|
2017-12-04 06:30:39 -05:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return kubernetes.RunRemove(kli, opts)
|
|
|
|
}
|
|
|
|
return swarm.RunRemove(dockerCli, opts)
|
|
|
|
},
|
|
|
|
}
|
|
|
|
return cmd
|
|
|
|
}
|