diff --git a/connector/github/github.go b/connector/github/github.go index 29986baa..9062e1ae 100644 --- a/connector/github/github.go +++ b/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 } diff --git a/connector/github/github_test.go b/connector/github/github_test.go index d9b89a98..721c0695 100644 --- a/connector/github/github_test.go +++ b/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",