Browse code

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>

Drew Erny authored on 2016/06/15 09:50:02
Showing 1 changed files
... ...
@@ -16,7 +16,7 @@ import (
16 16
 )
17 17
 
18 18
 const (
19
-	listItemFmt = "%s\t%s\t%s\t%s\t%s\t%s\t%s\n"
19
+	listItemFmt = "%s\t%s\t%s\t%s\t%s\t%s\n"
20 20
 )
21 21
 
22 22
 type listOptions struct {
... ...
@@ -74,7 +74,7 @@ func printTable(out io.Writer, nodes []swarm.Node, info types.Info) {
74 74
 	// Ignore flushing errors
75 75
 	defer writer.Flush()
76 76
 
77
-	fmt.Fprintf(writer, listItemFmt, "ID", "NAME", "MEMBERSHIP", "STATUS", "AVAILABILITY", "MANAGER STATUS", "LEADER")
77
+	fmt.Fprintf(writer, listItemFmt, "ID", "NAME", "MEMBERSHIP", "STATUS", "AVAILABILITY", "MANAGER STATUS")
78 78
 	for _, node := range nodes {
79 79
 		name := node.Spec.Name
80 80
 		availability := string(node.Spec.Availability)
... ...
@@ -84,14 +84,13 @@ func printTable(out io.Writer, nodes []swarm.Node, info types.Info) {
84 84
 			name = node.Description.Hostname
85 85
 		}
86 86
 
87
-		leader := ""
88
-		if node.ManagerStatus != nil && node.ManagerStatus.Leader {
89
-			leader = "Yes"
90
-		}
91
-
92 87
 		reachability := ""
93 88
 		if node.ManagerStatus != nil {
94
-			reachability = string(node.ManagerStatus.Reachability)
89
+			if node.ManagerStatus.Leader {
90
+				reachability = "Leader"
91
+			} else {
92
+				reachability = string(node.ManagerStatus.Reachability)
93
+			}
95 94
 		}
96 95
 
97 96
 		ID := node.ID
... ...
@@ -107,8 +106,7 @@ func printTable(out io.Writer, nodes []swarm.Node, info types.Info) {
107 107
 			client.PrettyPrint(membership),
108 108
 			client.PrettyPrint(string(node.Status.State)),
109 109
 			client.PrettyPrint(availability),
110
-			client.PrettyPrint(reachability),
111
-			leader)
110
+			client.PrettyPrint(reachability))
112 111
 	}
113 112
 }
114 113