mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
12a00e6017
As described in our ROADMAP.md, introduce new Swarm management commands to call to the corresponding API endpoints. This PR is fully backward compatible (joining a Swarm is an optional feature of the Engine, and existing commands are not impacted). Signed-off-by: Daniel Nephin <dnephin@docker.com> Signed-off-by: Victor Vieux <vieux@docker.com> Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
36 lines
794 B
Go
36 lines
794 B
Go
package node
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
"github.com/docker/docker/api/client"
|
|
"github.com/docker/docker/cli"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
func newRemoveCommand(dockerCli *client.DockerCli) *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "rm NODE [NODE...]",
|
|
Aliases: []string{"remove"},
|
|
Short: "Remove a node from the swarm",
|
|
Args: cli.RequiresMinArgs(1),
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
return runRemove(dockerCli, args)
|
|
},
|
|
}
|
|
}
|
|
|
|
func runRemove(dockerCli *client.DockerCli, args []string) error {
|
|
client := dockerCli.Client()
|
|
ctx := context.Background()
|
|
for _, nodeID := range args {
|
|
err := client.NodeRemove(ctx, nodeID)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
fmt.Fprintf(dockerCli.Out(), "%s\n", nodeID)
|
|
}
|
|
return nil
|
|
}
|