github.com/kobeld/docker@v1.12.0-rc1/api/client/node/remove.go (about) 1 package node 2 3 import ( 4 "fmt" 5 6 "golang.org/x/net/context" 7 8 "github.com/docker/docker/api/client" 9 "github.com/docker/docker/cli" 10 "github.com/spf13/cobra" 11 ) 12 13 func newRemoveCommand(dockerCli *client.DockerCli) *cobra.Command { 14 return &cobra.Command{ 15 Use: "rm NODE [NODE...]", 16 Aliases: []string{"remove"}, 17 Short: "Remove a node from the swarm", 18 Args: cli.RequiresMinArgs(1), 19 RunE: func(cmd *cobra.Command, args []string) error { 20 return runRemove(dockerCli, args) 21 }, 22 } 23 } 24 25 func runRemove(dockerCli *client.DockerCli, args []string) error { 26 client := dockerCli.Client() 27 ctx := context.Background() 28 for _, nodeID := range args { 29 err := client.NodeRemove(ctx, nodeID) 30 if err != nil { 31 return err 32 } 33 fmt.Fprintf(dockerCli.Out(), "%s\n", nodeID) 34 } 35 return nil 36 }