cli: show leader status in json output of server members (#17138)
This commit is contained in:
parent
7e56ca62d1
commit
4073987de3
|
@ -0,0 +1,3 @@
|
||||||
|
```release-note:improvement
|
||||||
|
cli: Add leader status to output of `nomad server members -json`
|
||||||
|
```
|
|
@ -118,7 +118,13 @@ func (c *ServerMembersCommand) Run(args []string) int {
|
||||||
// Sort the members
|
// Sort the members
|
||||||
sort.Sort(api.AgentMembersNameSort(srvMembers.Members))
|
sort.Sort(api.AgentMembersNameSort(srvMembers.Members))
|
||||||
|
|
||||||
|
// Determine the leaders per region.
|
||||||
|
leaders, leaderErr := regionLeaders(client, srvMembers.Members)
|
||||||
|
|
||||||
if json || len(tmpl) > 0 {
|
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)
|
out, err := Format(json, tmpl, srvMembers.Members)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Ui.Error(err.Error())
|
c.Ui.Error(err.Error())
|
||||||
|
@ -129,9 +135,6 @@ func (c *ServerMembersCommand) Run(args []string) int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine the leaders per region.
|
|
||||||
leaders, leaderErr := regionLeaders(client, srvMembers.Members)
|
|
||||||
|
|
||||||
// Format the list
|
// Format the list
|
||||||
var out []string
|
var out []string
|
||||||
if verbose {
|
if verbose {
|
||||||
|
|
Loading…
Reference in New Issue