cli: sort Node value in `nomad operator raft list-peers` command (#16221)
Signed-off-by: dttung2905 <ttdao.2015@accountancy.smu.edu.sg>
This commit is contained in:
parent
4b01df1787
commit
ed31e0a5f5
|
@ -0,0 +1,3 @@
|
|||
```release-note:improvement
|
||||
cli: Sort output by Node name of the command `nomad operator raft list-peers`
|
||||
```
|
|
@ -2,6 +2,7 @@ package command
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/nomad/api"
|
||||
|
@ -84,6 +85,10 @@ func (c *OperatorRaftListCommand) Run(args []string) int {
|
|||
|
||||
// Format it as a nice table.
|
||||
result := []string{"Node|ID|Address|State|Voter|RaftProtocol"}
|
||||
sort.Slice(reply.Servers, func(i, j int) bool {
|
||||
return reply.Servers[i].Node < reply.Servers[j].Node
|
||||
})
|
||||
|
||||
for _, s := range reply.Servers {
|
||||
state := "follower"
|
||||
if s.Leader {
|
||||
|
|
Loading…
Reference in New Issue