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

Function printJoinCommand

cli/command/swarm/join_token.go:101–130  ·  view source on GitHub ↗
(ctx context.Context, dockerCLI command.Cli, nodeID string, worker bool, manager bool)

Source from the content-addressed store, hash-verified

99}
100
101func 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}

Callers 2

runInitFunction · 0.85
runJoinTokenFunction · 0.85

Calls 4

SwarmInspectMethod · 0.80
ClientMethod · 0.65
OutMethod · 0.65
NodeInspectMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…