Skip to content

Commit

Permalink
Merge pull request #360 from smacker/installations_pagination
Browse files Browse the repository at this point in the history
Use pagination for installations too
  • Loading branch information
smacker authored Nov 20, 2018
2 parents dd84f0b + c704907 commit 1f29d62
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions provider/github/installations.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,25 @@ func NewInstallations(
func (t *Installations) Sync() error {
log.Infof("syncing installations with github")

installations, _, err := t.appClient.Apps.ListInstallations(context.TODO(), &github.ListOptions{})
if err != nil {
return err
var installations []*github.Installation
opts := &github.ListOptions{
PerPage: 100,
}
for {
installs, resp, err := t.appClient.Apps.ListInstallations(context.TODO(), opts)
if err != nil {
return err
}

installations = append(installations, installs...)

if resp.NextPage == 0 {
break
}

opts.Page = resp.NextPage
}

log.Debugf("found %d installations", len(installations))

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

0 comments on commit 1f29d62

Please sign in to comment.