Sort members in by name for consul members
This commit is contained in:
parent
bec5ce6af9
commit
263fae2292
|
@ -96,6 +96,8 @@ func (c *MembersCommand) Run(args []string) int {
|
||||||
return 2
|
return 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sort.Sort(ByMemberName(members))
|
||||||
|
|
||||||
// Generate the output
|
// Generate the output
|
||||||
var result []string
|
var result []string
|
||||||
if detailed {
|
if detailed {
|
||||||
|
@ -111,6 +113,13 @@ func (c *MembersCommand) Run(args []string) int {
|
||||||
return 0
|
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
|
// standardOutput is used to dump the most useful information about nodes
|
||||||
// in a more human-friendly format
|
// in a more human-friendly format
|
||||||
func (c *MembersCommand) standardOutput(members []agent.Member) []string {
|
func (c *MembersCommand) standardOutput(members []agent.Member) []string {
|
||||||
|
|
Loading…
Reference in New Issue