Skip to content

Commit 6fe0d81

Browse files
committed
GitHub provider: limit to 10 pages of organizations/teams
1 parent 4b99b4d commit 6fe0d81

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

providers/github.go

+3-8
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,18 @@ func (p *GitHubProvider) SetOrgTeam(org, team string) {
5858

5959
func (p *GitHubProvider) hasOrg(accessToken string) (bool, error) {
6060
// https://developer.github.com/v3/orgs/#list-your-organizations
61-
6261
var orgs []struct {
6362
Login string `json:"login"`
6463
}
65-
6664
type orgsPage []struct {
6765
Login string `json:"login"`
6866
}
6967

70-
pn := 1
71-
for {
68+
for pn := 1; pn <= 10; pn++ {
7269
params := url.Values{
7370
"limit": {"100"},
7471
"page": {strconv.Itoa(pn)},
7572
}
76-
7773
endpoint := &url.URL{
7874
Scheme: p.ValidateURL.Scheme,
7975
Host: p.ValidateURL.Host,
@@ -107,7 +103,6 @@ func (p *GitHubProvider) hasOrg(accessToken string) (bool, error) {
107103
}
108104

109105
orgs = append(orgs, op...)
110-
pn += 1
111106
}
112107

113108
var presentOrgs []string
@@ -137,7 +132,6 @@ func (p *GitHubProvider) hasOrgAndTeam(accessToken string) (bool, error) {
137132
params := url.Values{
138133
"limit": {"100"},
139134
}
140-
141135
endpoint := &url.URL{
142136
Scheme: p.ValidateURL.Scheme,
143137
Host: p.ValidateURL.Host,
@@ -150,7 +144,8 @@ func (p *GitHubProvider) hasOrgAndTeam(accessToken string) (bool, error) {
150144
var hasOrg bool
151145
presentOrgs := make(map[string]bool)
152146
var presentTeams []string
153-
for {
147+
148+
for i := 0; i < 10; i++ {
154149
req, _ := http.NewRequest("GET", team_url, nil)
155150
req.Header.Set("Accept", "application/vnd.github.hellcat-preview+json")
156151
req.Header.Set("Authorization", fmt.Sprintf("token %s", accessToken))

0 commit comments

Comments
 (0)