Browse Source

Unique groups

Signed-off-by: Imran Ismail <imran.codely@gmail.com>
pull/1828/head
Imran Ismail 6 years ago
parent
commit
c123abf177
  1. 26
      connector/github/github.go
  2. 1
      connector/github/github_test.go

26
connector/github/github.go

@ -460,6 +460,20 @@ func (c *githubConnector) userOrgTeams(ctx context.Context, client *http.Client)
groups[t.Org.Login] = append(groups[t.Org.Login], c.teamGroupClaims(t)...)
}
for _, t := range teams {
keys := make(map[string]bool)
uniqueGroups := []string{}
for _, group := range groups[t.Org.Login] {
if _, exists := keys[group]; !exists {
keys[group] = true
uniqueGroups = append(uniqueGroups, group)
}
groups[t.Org.Login] = uniqueGroups
}
}
if apiURL == "" {
break
}
@ -687,6 +701,18 @@ func (c *githubConnector) teamsForOrg(ctx context.Context, client *http.Client,
}
}
keys := make(map[string]bool)
uniqueGroups := []string{}
for _, group := range groups {
if _, exists := keys[group]; !exists {
keys[group] = true
uniqueGroups = append(uniqueGroups, group)
}
}
groups = uniqueGroups
if apiURL == "" {
break
}

1
connector/github/github_test.go

@ -56,7 +56,6 @@ func TestUserGroups(t *testing.T) {
"org-1",
"org-1:team-0",
"org-1:team-1",
"org-1:team-0",
"org-1:team-2",
"org-1:team-3",
"org-2",

Loading…
Cancel
Save