MCPcopy Index your code
hub / github.com/docker/cli / newJoinCommand

Function newJoinCommand

cli/command/swarm/join.go:26–54  ·  view source on GitHub ↗
(dockerCLI command.Cli)

Source from the content-addressed store, hash-verified

24}
25
26func newJoinCommand(dockerCLI command.Cli) *cobra.Command {
27 opts := joinOptions{
28 listenAddr: NewListenAddrOption(),
29 }
30
31 cmd := &cobra.Command{
32 Use: "join [OPTIONS] HOST:PORT",
33 Short: "Join a swarm as a node and/or manager",
34 Args: cli.ExactArgs(1),
35 RunE: func(cmd *cobra.Command, args []string) error {
36 opts.remote = args[0]
37 return runJoin(cmd.Context(), dockerCLI, cmd.Flags(), opts)
38 },
39 Annotations: map[string]string{
40 "version": "1.24",
41 "swarm": "", // swarm join does not require swarm to be active, and is always available on API 1.24 and up
42 },
43 DisableFlagsInUseLine: true,
44 }
45
46 flags := cmd.Flags()
47 flags.Var(&opts.listenAddr, flagListenAddr, `Listen address (format: "<ip|interface>[:port]")`)
48 flags.StringVar(&opts.advertiseAddr, flagAdvertiseAddr, "", `Advertised address (format: "<ip|interface>[:port]")`)
49 flags.StringVar(&opts.dataPathAddr, flagDataPathAddr, "", `Address or interface to use for data path traffic (format: "<ip|interface>")`)
50 flags.SetAnnotation(flagDataPathAddr, "version", []string{"1.31"})
51 flags.StringVar(&opts.token, flagToken, "", "Token for entry into the swarm")
52 flags.StringVar(&opts.availability, flagAvailability, "active", `Availability of the node ("active", "pause", "drain")`)
53 return cmd
54}
55
56func runJoin(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, opts joinOptions) error {
57 apiClient := dockerCLI.Client()

Callers 3

newSwarmCommandFunction · 0.85
TestSwarmJoinErrorsFunction · 0.85
TestSwarmJoinFunction · 0.85

Calls 2

NewListenAddrOptionFunction · 0.85
runJoinFunction · 0.85

Tested by 2

TestSwarmJoinErrorsFunction · 0.68
TestSwarmJoinFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…