(dockerCLI command.Cli)
| 10 | ) |
| 11 | |
| 12 | func newLeaveCommand(dockerCLI command.Cli) *cobra.Command { |
| 13 | var opts client.SwarmLeaveOptions |
| 14 | |
| 15 | cmd := &cobra.Command{ |
| 16 | Use: "leave [OPTIONS]", |
| 17 | Short: "Leave the swarm", |
| 18 | Args: cli.NoArgs, |
| 19 | RunE: func(cmd *cobra.Command, args []string) error { |
| 20 | if _, err := dockerCLI.Client().SwarmLeave(cmd.Context(), opts); err != nil { |
| 21 | return err |
| 22 | } |
| 23 | |
| 24 | _, _ = fmt.Fprintln(dockerCLI.Out(), "Node left the swarm.") |
| 25 | return nil |
| 26 | }, |
| 27 | Annotations: map[string]string{ |
| 28 | "version": "1.24", |
| 29 | "swarm": "active", |
| 30 | }, |
| 31 | ValidArgsFunction: cobra.NoFileCompletions, |
| 32 | DisableFlagsInUseLine: true, |
| 33 | } |
| 34 | |
| 35 | flags := cmd.Flags() |
| 36 | flags.BoolVarP(&opts.Force, "force", "f", false, "Force this node to leave the swarm, ignoring warnings") |
| 37 | return cmd |
| 38 | } |
searching dependent graphs…