Skip to content

Commit 1f29d62

Browse files
authored
Merge pull request #360 from smacker/installations_pagination
Use pagination for installations too
2 parents dd84f0b + c704907 commit 1f29d62

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

provider/github/installations.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,25 @@ func NewInstallations(
7171
func (t *Installations) Sync() error {
7272
log.Infof("syncing installations with github")
7373

74-
installations, _, err := t.appClient.Apps.ListInstallations(context.TODO(), &github.ListOptions{})
75-
if err != nil {
76-
return err
74+
var installations []*github.Installation
75+
opts := &github.ListOptions{
76+
PerPage: 100,
7777
}
78+
for {
79+
installs, resp, err := t.appClient.Apps.ListInstallations(context.TODO(), opts)
80+
if err != nil {
81+
return err
82+
}
83+
84+
installations = append(installations, installs...)
85+
86+
if resp.NextPage == 0 {
87+
break
88+
}
89+
90+
opts.Page = resp.NextPage
91+
}
92+
7893
log.Debugf("found %d installations", len(installations))
7994

8095
new := make(map[int64]*github.Installation, len(installations))

0 commit comments

Comments
 (0)