Skip to content

Commit

Permalink
Merge pull request etcd-io#6 from jingyih/add_learner_field_to_Member…
Browse files Browse the repository at this point in the history
…List

etcdctl: add learner field in member list output
  • Loading branch information
jingyih authored Mar 21, 2019
2 parents 04267b9 + e7146d2 commit a1408c5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion etcdctl/ctlv3/command/member_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func NewMemberListCommand() *cobra.Command {
Use: "list",
Short: "Lists all members in the cluster",
Long: `When --write-out is set to simple, this command prints out comma-separated member lists for each endpoint.
The items in the lists are ID, Status, Name, Peer Addrs, Client Addrs.
The items in the lists are ID, Status, Name, Peer Addrs, Client Addrs, Is Learner.
`,

Run: memberListCommandFunc,
Expand Down
7 changes: 6 additions & 1 deletion etcdctl/ctlv3/command/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,23 @@ func (p *printerUnsupported) DBStatus(snapshot.Status) { p.p(nil) }
func (p *printerUnsupported) MoveLeader(leader, target uint64, r v3.MoveLeaderResponse) { p.p(nil) }

func makeMemberListTable(r v3.MemberListResponse) (hdr []string, rows [][]string) {
hdr = []string{"ID", "Status", "Name", "Peer Addrs", "Client Addrs"}
hdr = []string{"ID", "Status", "Name", "Peer Addrs", "Client Addrs", "Is Learner"}
for _, m := range r.Members {
status := "started"
if len(m.Name) == 0 {
status = "unstarted"
}
isLearner := "false"
if m.IsLearner {
isLearner = "true"
}
rows = append(rows, []string{
fmt.Sprintf("%x", m.ID),
status,
m.Name,
strings.Join(m.PeerURLs, ","),
strings.Join(m.ClientURLs, ","),
isLearner,
})
}
return hdr, rows
Expand Down
1 change: 1 addition & 0 deletions etcdctl/ctlv3/command/printer_fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func (p *fieldsPrinter) MemberList(r v3.MemberListResponse) {
for _, u := range m.ClientURLs {
fmt.Printf("\"ClientURL\" : %q\n", u)
}
fmt.Println(`"IsLearner" :`, m.IsLearner)
fmt.Println()
}
}
Expand Down

0 comments on commit a1408c5

Please sign in to comment.