Skip to content

Commit

Permalink
Add pagination to github_external_groups data source (#1688)
Browse files Browse the repository at this point in the history
Fixes #1687
  • Loading branch information
bodgit authored May 18, 2023
1 parent ce50fe0 commit 49b2376
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions github/data_source_github_external_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,20 @@ func dataSourceGithubExternalGroupsRead(d *schema.ResourceData, meta interface{}
ctx := context.WithValue(context.Background(), ctxId, d.Id())
opts := &github.ListExternalGroupsOptions{}

externalGroups, _, err := client.Teams.ListExternalGroups(ctx, orgName, opts)
if err != nil {
return err
externalGroups := new(github.ExternalGroupList)

for {
groups, resp, err := client.Teams.ListExternalGroups(ctx, orgName, opts)
if err != nil {
return err
}

externalGroups.Groups = append(externalGroups.Groups, groups.Groups...)

if resp.NextPage == 0 {
break
}
opts.Page = resp.NextPage
}

// convert to JSON in order to martial to format we can return
Expand Down

0 comments on commit 49b2376

Please sign in to comment.