Skip to content

Commit 49b2376

Browse files
authored
Add pagination to github_external_groups data source (#1688)
Fixes #1687
1 parent ce50fe0 commit 49b2376

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

github/data_source_github_external_groups.go

+14-3
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,20 @@ func dataSourceGithubExternalGroupsRead(d *schema.ResourceData, meta interface{}
4848
ctx := context.WithValue(context.Background(), ctxId, d.Id())
4949
opts := &github.ListExternalGroupsOptions{}
5050

51-
externalGroups, _, err := client.Teams.ListExternalGroups(ctx, orgName, opts)
52-
if err != nil {
53-
return err
51+
externalGroups := new(github.ExternalGroupList)
52+
53+
for {
54+
groups, resp, err := client.Teams.ListExternalGroups(ctx, orgName, opts)
55+
if err != nil {
56+
return err
57+
}
58+
59+
externalGroups.Groups = append(externalGroups.Groups, groups.Groups...)
60+
61+
if resp.NextPage == 0 {
62+
break
63+
}
64+
opts.Page = resp.NextPage
5465
}
5566

5667
// convert to JSON in order to martial to format we can return

0 commit comments

Comments
 (0)