mirror of https://github.com/status-im/consul.git
Sort members in by name for consul members
This commit is contained in:
parent
6aa21152d1
commit
7d0959b34e
|
@ -96,6 +96,8 @@ func (c *MembersCommand) Run(args []string) int {
|
|||
return 2
|
||||
}
|
||||
|
||||
sort.Sort(ByMemberName(members))
|
||||
|
||||
// Generate the output
|
||||
var result []string
|
||||
if detailed {
|
||||
|
@ -111,6 +113,13 @@ func (c *MembersCommand) Run(args []string) int {
|
|||
return 0
|
||||
}
|
||||
|
||||
// so we can sort members by name
|
||||
type ByMemberName []agent.Member
|
||||
|
||||
func (m ByMemberName) Len() int { return len(m) }
|
||||
func (m ByMemberName) Swap(i, j int) { m[i], m[j] = m[j], m[i] }
|
||||
func (m ByMemberName) Less(i, j int) bool { return m[i].Name < m[j].Name }
|
||||
|
||||
// standardOutput is used to dump the most useful information about nodes
|
||||
// in a more human-friendly format
|
||||
func (c *MembersCommand) standardOutput(members []agent.Member) []string {
|
||||
|
|
Loading…
Reference in New Issue