Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: Fetch all GitHub teams on login
This wasn't looping prior, so organizations with >100 teams
couldn't login. Contributes to #2848.
  • Loading branch information
kylecarbs committed Jul 12, 2022
commit f19472c63dc040acf34d7b799b175c727c429eca
19 changes: 16 additions & 3 deletions cli/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -771,10 +771,23 @@ func configureGithubOAuth2(accessURL *url.URL, clientID, clientSecret string, al
return memberships, err
},
ListTeams: func(ctx context.Context, client *http.Client, org string) ([]*github.Team, error) {
teams, _, err := github.NewClient(client).Teams.ListTeams(ctx, org, &github.ListOptions{
opt := &github.ListOptions{
// This is the maximum amount per-page that GitHub allows.
PerPage: 100,
})
return teams, err
}
var allTeams []*github.Team
for {
teams, resp, err := github.NewClient(client).Teams.ListTeams(ctx, org, opt)
if err != nil {
return nil, err
}
allTeams = append(allTeams, teams...)
if resp.NextPage == 0 {
break
}
opt.Page = resp.NextPage
}
return allTeams, nil
},
}, nil
}
Expand Down