1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Remove the node leader column, show leader as status.

Removes the leader column from node ls and shows whether a node is the
leader in the manager status column instead.

Signed-off-by: Drew Erny <drew.erny@docker.com>
This commit is contained in:
Drew Erny 2016-06-14 17:50:02 -07:00
parent 6ed921dc38
commit 4104c1dc13

View file

@ -16,7 +16,7 @@ import (
) )
const ( const (
listItemFmt = "%s\t%s\t%s\t%s\t%s\t%s\t%s\n" listItemFmt = "%s\t%s\t%s\t%s\t%s\t%s\n"
) )
type listOptions struct { type listOptions struct {
@ -74,7 +74,7 @@ func printTable(out io.Writer, nodes []swarm.Node, info types.Info) {
// Ignore flushing errors // Ignore flushing errors
defer writer.Flush() defer writer.Flush()
fmt.Fprintf(writer, listItemFmt, "ID", "NAME", "MEMBERSHIP", "STATUS", "AVAILABILITY", "MANAGER STATUS", "LEADER") fmt.Fprintf(writer, listItemFmt, "ID", "NAME", "MEMBERSHIP", "STATUS", "AVAILABILITY", "MANAGER STATUS")
for _, node := range nodes { for _, node := range nodes {
name := node.Spec.Name name := node.Spec.Name
availability := string(node.Spec.Availability) availability := string(node.Spec.Availability)
@ -84,15 +84,14 @@ func printTable(out io.Writer, nodes []swarm.Node, info types.Info) {
name = node.Description.Hostname name = node.Description.Hostname
} }
leader := ""
if node.ManagerStatus != nil && node.ManagerStatus.Leader {
leader = "Yes"
}
reachability := "" reachability := ""
if node.ManagerStatus != nil { if node.ManagerStatus != nil {
if node.ManagerStatus.Leader {
reachability = "Leader"
} else {
reachability = string(node.ManagerStatus.Reachability) reachability = string(node.ManagerStatus.Reachability)
} }
}
ID := node.ID ID := node.ID
if node.ID == info.Swarm.NodeID { if node.ID == info.Swarm.NodeID {
@ -107,8 +106,7 @@ func printTable(out io.Writer, nodes []swarm.Node, info types.Info) {
client.PrettyPrint(membership), client.PrettyPrint(membership),
client.PrettyPrint(string(node.Status.State)), client.PrettyPrint(string(node.Status.State)),
client.PrettyPrint(availability), client.PrettyPrint(availability),
client.PrettyPrint(reachability), client.PrettyPrint(reachability))
leader)
} }
} }