Skip to content

Commit

Permalink
cli: show leader status in json output of server members (#17138)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yethal authored May 18, 2023
1 parent 4335f9f commit 93fc71b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .changelog/17138.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
cli: Add leader status to output of `nomad server members -json`
```
9 changes: 6 additions & 3 deletions command/server_members.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,13 @@ func (c *ServerMembersCommand) Run(args []string) int {
// Sort the members
sort.Sort(api.AgentMembersNameSort(srvMembers.Members))

// Determine the leaders per region.
leaders, leaderErr := regionLeaders(client, srvMembers.Members)

if json || len(tmpl) > 0 {
for _, member := range srvMembers.Members {
member.Tags["Leader"] = fmt.Sprintf("%t", isLeader(member, leaders))
}
out, err := Format(json, tmpl, srvMembers.Members)
if err != nil {
c.Ui.Error(err.Error())
Expand All @@ -129,9 +135,6 @@ func (c *ServerMembersCommand) Run(args []string) int {
return 0
}

// Determine the leaders per region.
leaders, leaderErr := regionLeaders(client, srvMembers.Members)

// Format the list
var out []string
if verbose {
Expand Down

0 comments on commit 93fc71b

Please sign in to comment.