From 6b76d591b4a21bcd8551360a14be0bd4d35e0131 Mon Sep 17 00:00:00 2001 From: Ashesh Vidyut Date: Fri, 9 Jun 2023 21:49:22 +0530 Subject: [PATCH] nits --- .../operator/raft/listpeers/operator_raft_list.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/command/operator/raft/listpeers/operator_raft_list.go b/command/operator/raft/listpeers/operator_raft_list.go index 495b2f64d185..29643a87cf33 100644 --- a/command/operator/raft/listpeers/operator_raft_list.go +++ b/command/operator/raft/listpeers/operator_raft_list.go @@ -99,21 +99,19 @@ func raftListPeers(client *api.Client, stale bool) (string, error) { state = "leader" } + trailsLeaderByText := "-" serverLastIndex, ok := serverIdLastIndexMap[s.ID] if ok { trailsLeaderBy := leaderLastCommitIndex - serverLastIndex - trailsLeaderByText := fmt.Sprintf("%d commits", trailsLeaderBy) + trailsLeaderByText = fmt.Sprintf("%d commits", trailsLeaderBy) if s.Leader { trailsLeaderByText = "-" - } else if trailsLeaderBy <= 1 { + } else if trailsLeaderBy == 1 { trailsLeaderByText = fmt.Sprintf("%d commit", trailsLeaderBy) } - result = append(result, fmt.Sprintf("%s\x1f%s\x1f%s\x1f%s\x1f%v\x1f%s\x1f%v\x1f%s", - s.Node, s.ID, s.Address, state, s.Voter, raftProtocol, serverLastIndex, trailsLeaderByText)) - } else { - result = append(result, fmt.Sprintf("%s\x1f%s\x1f%s\x1f%s\x1f%v\x1f%s\x1f%v", - s.Node, s.ID, s.Address, state, s.Voter, raftProtocol, "-")) } + result = append(result, fmt.Sprintf("%s\x1f%s\x1f%s\x1f%s\x1f%v\x1f%s\x1f%v\x1f%s", + s.Node, s.ID, s.Address, state, s.Voter, raftProtocol, serverLastIndex, trailsLeaderByText)) } return columnize.Format(result, &columnize.Config{Delim: string([]byte{0x1f})}), nil