mirror of
https://github.com/status-im/consul.git
synced 2025-01-20 18:50:04 +00:00
Include DC in the members command output
This commit is contained in:
parent
cf9d499e94
commit
ed3b0dd9ee
@ -114,7 +114,7 @@ func (c *MembersCommand) Run(args []string) int {
|
|||||||
// in a more human-friendly format
|
// in a more human-friendly format
|
||||||
func (c *MembersCommand) standardOutput(members []agent.Member) []string {
|
func (c *MembersCommand) standardOutput(members []agent.Member) []string {
|
||||||
result := make([]string, 0, len(members))
|
result := make([]string, 0, len(members))
|
||||||
header := "Node|Address|Status|Type|Build|Protocol"
|
header := "Node|Address|Status|Type|Build|Protocol|DC"
|
||||||
result = append(result, header)
|
result = append(result, header)
|
||||||
for _, member := range members {
|
for _, member := range members {
|
||||||
addr := net.TCPAddr{IP: member.Addr, Port: int(member.Port)}
|
addr := net.TCPAddr{IP: member.Addr, Port: int(member.Port)}
|
||||||
@ -125,18 +125,19 @@ func (c *MembersCommand) standardOutput(members []agent.Member) []string {
|
|||||||
} else if idx := strings.Index(build, ":"); idx != -1 {
|
} else if idx := strings.Index(build, ":"); idx != -1 {
|
||||||
build = build[:idx]
|
build = build[:idx]
|
||||||
}
|
}
|
||||||
|
dc := member.Tags["dc"]
|
||||||
|
|
||||||
switch member.Tags["role"] {
|
switch member.Tags["role"] {
|
||||||
case "node":
|
case "node":
|
||||||
line := fmt.Sprintf("%s|%s|%s|client|%s|%s",
|
line := fmt.Sprintf("%s|%s|%s|client|%s|%s|%s",
|
||||||
member.Name, addr.String(), member.Status, build, protocol)
|
member.Name, addr.String(), member.Status, build, protocol, dc)
|
||||||
result = append(result, line)
|
result = append(result, line)
|
||||||
case "consul":
|
case "consul":
|
||||||
line := fmt.Sprintf("%s|%s|%s|server|%s|%s",
|
line := fmt.Sprintf("%s|%s|%s|server|%s|%s|%s",
|
||||||
member.Name, addr.String(), member.Status, build, protocol)
|
member.Name, addr.String(), member.Status, build, protocol, dc)
|
||||||
result = append(result, line)
|
result = append(result, line)
|
||||||
default:
|
default:
|
||||||
line := fmt.Sprintf("%s|%s|%s|unknown||",
|
line := fmt.Sprintf("%s|%s|%s|unknown|||",
|
||||||
member.Name, addr.String(), member.Status)
|
member.Name, addr.String(), member.Status)
|
||||||
result = append(result, line)
|
result = append(result, line)
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,20 @@ func TestMembersCommandRun(t *testing.T) {
|
|||||||
t.Fatalf("bad: %d. %#v", code, ui.ErrorWriter.String())
|
t.Fatalf("bad: %d. %#v", code, ui.ErrorWriter.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Name
|
||||||
if !strings.Contains(ui.OutputWriter.String(), a1.config.NodeName) {
|
if !strings.Contains(ui.OutputWriter.String(), a1.config.NodeName) {
|
||||||
t.Fatalf("bad: %#v", ui.OutputWriter.String())
|
t.Fatalf("bad: %#v", ui.OutputWriter.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Agent type
|
||||||
|
if !strings.Contains(ui.OutputWriter.String(), "server") {
|
||||||
|
t.Fatalf("bad: %#v", ui.OutputWriter.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Datacenter
|
||||||
|
if !strings.Contains(ui.OutputWriter.String(), "dc1") {
|
||||||
|
t.Fatalf("bad: %#v", ui.OutputWriter.String())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMembersCommandRun_WAN(t *testing.T) {
|
func TestMembersCommandRun_WAN(t *testing.T) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user