From 74d635e9c69e8bdd5a0d59d7c6ba251c4077f98d Mon Sep 17 00:00:00 2001 From: James Phillips Date: Tue, 5 Sep 2017 11:46:44 -0700 Subject: [PATCH] Simplifies members command to not fetch segments. --- command/members.go | 41 ++++++++++++----------------------------- command/segment_stub.go | 16 ---------------- 2 files changed, 12 insertions(+), 45 deletions(-) delete mode 100644 command/segment_stub.go diff --git a/command/members.go b/command/members.go index 0feac08a02..f12912a4bb 100644 --- a/command/members.go +++ b/command/members.go @@ -65,32 +65,15 @@ func (c *MembersCommand) Run(args []string) int { return 1 } - // Check if we queried a server and need to query for members in all segments. - var members []*consulapi.AgentMember - if !wan && segment == "" { - self, err := client.Agent().Self() - if err != nil { - c.UI.Error(fmt.Sprintf("Error retrieving agent info: %s", err)) - return 1 - } - if self["Config"]["Server"].(bool) { - segmentMembers, err := getSegmentMembers(client) - if err != nil { - c.UI.Error(fmt.Sprintf("Error retrieving members in segments: %s", err)) - return 1 - } - members = segmentMembers - } - } else { - var err error - members, err = client.Agent().MembersOpts(consulapi.MembersOpts{ - WAN: wan, - Segment: segment, - }) - if err != nil { - c.UI.Error(fmt.Sprintf("Error retrieving members: %s", err)) - return 1 - } + // Make the request. + opts := consulapi.MembersOpts{ + Segment: segment, + WAN: wan, + } + members, err := client.Agent().MembersOpts(opts) + if err != nil { + c.UI.Error(fmt.Sprintf("Error retrieving members: %s", err)) + return 1 } // Filter the results @@ -99,9 +82,9 @@ func (c *MembersCommand) Run(args []string) int { member := members[i] if member.Tags["segment"] == "" { member.Tags["segment"] = "" - if member.Tags["role"] == "consul" { - member.Tags["segment"] = "" - } + } + if member.Tags["role"] == "consul" { + member.Tags["segment"] = "" } statusString := serf.MemberStatus(member.Status).String() if !statusRe.MatchString(statusString) { diff --git a/command/segment_stub.go b/command/segment_stub.go deleted file mode 100644 index bd5c5589a4..0000000000 --- a/command/segment_stub.go +++ /dev/null @@ -1,16 +0,0 @@ -// +build !ent - -package command - -import consulapi "github.com/hashicorp/consul/api" - -// getSegmentMembers returns an empty list since network segments are not -// supported in OSS Consul. -func getSegmentMembers(client *consulapi.Client) ([]*consulapi.AgentMember, error) { - members, err := client.Agent().MembersOpts(consulapi.MembersOpts{}) - if err != nil { - return nil, err - } - - return members, nil -}