1
0
mirror of https://github.com/docker/cli.git synced 2026-01-26 15:41:42 +03:00

change join node role judge

Signed-off-by: allencloud <allen.sun@daocloud.io>
Upstream-commit: e41c0370b4714892201728e0544b007e5e9f1b27
Component: engine
This commit is contained in:
allencloud
2016-10-19 14:35:05 +08:00
parent a787673664
commit 486047481e

View File

@@ -2,7 +2,6 @@ package swarm
import (
"fmt"
"strings"
"github.com/docker/docker/api/types/swarm"
"github.com/docker/docker/cli"
@@ -61,15 +60,10 @@ func runJoin(dockerCli *command.DockerCli, opts joinOptions) error {
return err
}
_, _, err = client.NodeInspectWithRaw(ctx, info.Swarm.NodeID)
if err != nil {
// TODO(aaronl): is there a better way to do this?
if strings.Contains(err.Error(), "This node is not a swarm manager.") {
fmt.Fprintln(dockerCli.Out(), "This node joined a swarm as a worker.")
}
} else {
if info.Swarm.ControlAvailable {
fmt.Fprintln(dockerCli.Out(), "This node joined a swarm as a manager.")
} else {
fmt.Fprintln(dockerCli.Out(), "This node joined a swarm as a worker.")
}
return nil
}