Skip to content

Commit

Permalink
Fix data_group_users in the face of pagination (#45)
Browse files Browse the repository at this point in the history
* Without this change, past the first page of results, the
  pagination logic within data_group_users was incorrectly switching
  to the data_project_permissions_groups API, as well as not actually
  updating the API URL, resulting in breakage for groups with >25 users.
  • Loading branch information
isometry authored Jun 16, 2022
1 parent 5311e3a commit 2e2fc4e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions bitbucket/data_group_users.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ package bitbucket
import (
"encoding/json"
"fmt"
"github.com/hashicorp/terraform/helper/schema"
"net/url"

"github.com/hashicorp/terraform/helper/schema"
)

type PaginatedGroupUsersValue struct {
Expand Down Expand Up @@ -96,7 +97,7 @@ func dataSourceGroupUsersRead(d *schema.ResourceData, m interface{}) error {
func readGroupUsers(m interface{}, group string, filter string) ([]GroupUser, error) {
client := m.(*BitbucketServerProvider).BitbucketClient

resourceURL := fmt.Sprintf("/rest/api/1.0/admin/groups/more-members?context=%s",
resourceURL := fmt.Sprintf("/rest/api/1.0/admin/groups/more-members?context=%s&limit=100",
url.QueryEscape(group),
)

Expand Down Expand Up @@ -130,7 +131,7 @@ func readGroupUsers(m interface{}, group string, filter string) ([]GroupUser, er
}

if groupUsers.IsLastPage == false {
resourceURL = fmt.Sprintf("/rest/api/1.0/projects/%s/permissions/users?start=%d",
resourceURL = fmt.Sprintf("/rest/api/1.0/admin/groups/more-members?context=%s&limit=100&start=%d",
group,
groupUsers.NextPageStart,
)
Expand Down

0 comments on commit 2e2fc4e

Please sign in to comment.