(dockerCLI command.Cli)
| 24 | } |
| 25 | |
| 26 | func 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 | |
| 56 | func runJoin(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, opts joinOptions) error { |
| 57 | apiClient := dockerCLI.Client() |
searching dependent graphs…