(dockerCLI command.Cli)
| 16 | } |
| 17 | |
| 18 | func newRemoveCommand(dockerCLI command.Cli) *cobra.Command { |
| 19 | opts := removeOptions{} |
| 20 | |
| 21 | cmd := &cobra.Command{ |
| 22 | Use: "rm [OPTIONS] NODE [NODE...]", |
| 23 | Aliases: []string{"remove"}, |
| 24 | Short: "Remove one or more nodes from the swarm", |
| 25 | Args: cli.RequiresMinArgs(1), |
| 26 | RunE: func(cmd *cobra.Command, args []string) error { |
| 27 | return runRemove(cmd.Context(), dockerCLI, args, opts) |
| 28 | }, |
| 29 | ValidArgsFunction: completeNodeNames(dockerCLI), |
| 30 | DisableFlagsInUseLine: true, |
| 31 | } |
| 32 | flags := cmd.Flags() |
| 33 | flags.BoolVarP(&opts.force, "force", "f", false, "Force remove a node from the swarm") |
| 34 | return cmd |
| 35 | } |
| 36 | |
| 37 | func runRemove(ctx context.Context, dockerCLI command.Cli, nodeIDs []string, opts removeOptions) error { |
| 38 | apiClient := dockerCLI.Client() |
searching dependent graphs…