Skip to content

Commit 38182bd

Browse files
committed
[BB-1027] baton-github: use max_page_size
1 parent 16bcd96 commit 38182bd

File tree

6 files changed

+22
-9
lines changed

6 files changed

+22
-9
lines changed

pkg/connector/connector.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ import (
2929

3030
const githubDotCom = "https://github.com"
3131

32-
var ValidAssetDomains = []string{"avatars.githubusercontent.com"}
32+
var (
33+
ValidAssetDomains = []string{"avatars.githubusercontent.com"}
34+
max_page_size int = 100
35+
)
3336

3437
var (
3538
resourceTypeOrg = &v2.ResourceType{

pkg/connector/org.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func (o *orgResourceType) List(
9595

9696
opts := &github.ListOptions{
9797
Page: page,
98-
PerPage: pToken.Size,
98+
PerPage: max_page_size,
9999
}
100100

101101
orgs, resp, err := o.client.Organizations.List(ctx, "", opts)
@@ -188,7 +188,7 @@ func (o *orgResourceType) Grants(
188188
opts := github.ListMembersOptions{
189189
ListOptions: github.ListOptions{
190190
Page: page,
191-
PerPage: pToken.Size,
191+
PerPage: max_page_size,
192192
},
193193
}
194194

pkg/connector/org_role.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ func (o *orgRoleResourceType) Grants(
163163
})
164164
case resourceTypeUser.Id:
165165
opts := &github.ListOptions{
166-
Page: page,
166+
Page: page,
167+
PerPage: max_page_size,
167168
}
168169
users, resp, err := o.client.Organizations.ListUsersAssignedToOrgRole(ctx, orgName, roleID, opts)
169170
if err != nil {

pkg/connector/repository.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func (o *repositoryResourceType) List(ctx context.Context, parentID *v2.Resource
8282
opts := &github.RepositoryListByOrgOptions{
8383
ListOptions: github.ListOptions{
8484
Page: page,
85-
PerPage: pt.Size,
85+
PerPage: max_page_size,
8686
},
8787
}
8888

@@ -161,7 +161,10 @@ func (o *repositoryResourceType) Grants(
161161
case resourceTypeUser.Id:
162162
opts := &github.ListCollaboratorsOptions{
163163
Affiliation: "all",
164-
ListOptions: github.ListOptions{Page: page},
164+
ListOptions: github.ListOptions{
165+
Page: page,
166+
PerPage: max_page_size,
167+
},
165168
}
166169
users, resp, err := o.client.Repositories.ListCollaborators(ctx, orgName, resource.DisplayName, opts)
167170
if err != nil {

pkg/connector/team.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (o *teamResourceType) List(ctx context.Context, parentID *v2.ResourceId, pt
7878

7979
opts := &github.ListOptions{
8080
Page: page,
81-
PerPage: pt.Size,
81+
PerPage: max_page_size,
8282
}
8383

8484
orgID, err := parseResourceToGitHub(parentID)
@@ -175,7 +175,10 @@ func (o *teamResourceType) Grants(ctx context.Context, resource *v2.Resource, pT
175175
}
176176

177177
opts := github.TeamListTeamMembersOptions{
178-
ListOptions: github.ListOptions{Page: page},
178+
ListOptions: github.ListOptions{
179+
Page: page,
180+
PerPage: max_page_size,
181+
},
179182
}
180183

181184
users, resp, err := o.client.Teams.ListTeamMembersByID(ctx, org.GetID(), githubID, &opts)

pkg/connector/user.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ func (o *userResourceType) List(ctx context.Context, parentID *v2.ResourceId, pt
123123
var restApiRateLimit *v2.RateLimitDescription
124124

125125
opts := github.ListMembersOptions{
126-
ListOptions: github.ListOptions{Page: page, PerPage: pt.Size},
126+
ListOptions: github.ListOptions{
127+
Page: page,
128+
PerPage: max_page_size,
129+
},
127130
}
128131

129132
users, resp, err := o.client.Organizations.ListMembers(ctx, orgName, &opts)

0 commit comments

Comments
 (0)