(ctx context.Context, dockerCLI command.Cli, nodeID string, worker bool, manager bool)
| 99 | } |
| 100 | |
| 101 | func printJoinCommand(ctx context.Context, dockerCLI command.Cli, nodeID string, worker bool, manager bool) error { |
| 102 | apiClient := dockerCLI.Client() |
| 103 | |
| 104 | res, err := apiClient.NodeInspect(ctx, nodeID, client.NodeInspectOptions{}) |
| 105 | if err != nil { |
| 106 | return err |
| 107 | } |
| 108 | |
| 109 | sw, err := apiClient.SwarmInspect(ctx, client.SwarmInspectOptions{}) |
| 110 | if err != nil { |
| 111 | return err |
| 112 | } |
| 113 | |
| 114 | if res.Node.ManagerStatus != nil { |
| 115 | if worker { |
| 116 | _, _ = fmt.Fprintf(dockerCLI.Out(), |
| 117 | "To add a worker to this swarm, run the following command:\n\n docker swarm join --token %s %s\n\n", |
| 118 | sw.Swarm.JoinTokens.Worker, res.Node.ManagerStatus.Addr, |
| 119 | ) |
| 120 | } |
| 121 | if manager { |
| 122 | _, _ = fmt.Fprintf(dockerCLI.Out(), |
| 123 | "To add a manager to this swarm, run the following command:\n\n docker swarm join --token %s %s\n\n", |
| 124 | sw.Swarm.JoinTokens.Manager, res.Node.ManagerStatus.Addr, |
| 125 | ) |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | return nil |
| 130 | } |
no test coverage detected
searching dependent graphs…