-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathleave.go
More file actions
38 lines (32 loc) · 910 Bytes
/
leave.go
File metadata and controls
38 lines (32 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package swarm
import (
"fmt"
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/moby/moby/client"
"github.com/spf13/cobra"
)
func newLeaveCommand(dockerCLI command.Cli) *cobra.Command {
var opts client.SwarmLeaveOptions
cmd := &cobra.Command{
Use: "leave [OPTIONS]",
Short: "Leave the swarm",
Args: cli.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
if _, err := dockerCLI.Client().SwarmLeave(cmd.Context(), opts); err != nil {
return err
}
_, _ = fmt.Fprintln(dockerCLI.Out(), "Node left the swarm.")
return nil
},
Annotations: map[string]string{
"version": "1.24",
"swarm": "active",
},
ValidArgsFunction: cobra.NoFileCompletions,
DisableFlagsInUseLine: true,
}
flags := cmd.Flags()
flags.BoolVarP(&opts.Force, "force", "f", false, "Force this node to leave the swarm, ignoring warnings")
return cmd
}