Skip to content
This repository has been archived by the owner on Dec 8, 2020. It is now read-only.

Fix for bug where pagination was not happening #28

Merged
merged 1 commit into from
May 14, 2019
Merged

Fix for bug where pagination was not happening #28

merged 1 commit into from
May 14, 2019

Conversation

alucillo
Copy link

The BitBucket API returns a paginated list of results for the default reviewers. Each page is limited to 10 results.
This PR fixes a bug where the bitbucket_default_reviewers resource was not paginating results and as a result limited us to 10 default reviewers.

BEFORE: Incorrectly showing 10 default reviewers instead of 13

Terraform will perform the following actions:

-/+ bitbucket_default_reviewers.xyz (new resource required)
      id:                   "abc/xyz/reviewers" => <computed> (forces new resource)
      owner:                "abc" => "abc"
      repository:           "xyz" => "xyz"
      reviewers.#:          "10" => "12" (forces new resource)
      reviewers.2026587276: "" => "nester" (forces new resource)
      reviewers.2148309749: "joe" => "joe"
      reviewers.2149516979: "billy" => "billy"
      reviewers.236488699:  "bob" => "bob"
      reviewers.2449433192: "foo" => "foo"
      reviewers.2468887411: "soap" => "soap"
      reviewers.3486131507: "" => "bar" (forces new resource)
      reviewers.3510966834: "glow" => "glow"
      reviewers.380778529:  "sublime" => "sublime"
      reviewers.718298102:  "bit" => "bit"
      reviewers.801735074:  "bucket" => "bucket"
      reviewers.98717443:   "friend" => "friend"


Plan: 1 to add, 0 to change, 1 to destroy.

AFTER: Correctly showing 13 default reviewers that I want reduced to 12

Terraform will perform the following actions:

-/+ bitbucket_default_reviewers.xyz (new resource required)
      id:                   "abc/xyz/reviewers" => <computed> (forces new resource)
      owner:                "abc" => "abc"
      repository:           "xyz" => "xyz"
      reviewers.#:          "13" => "12" (forces new resource)
      reviewers.2026587276: "coffee" => "coffee"
      reviewers.2148309749: "nester" => "nester"
      reviewers.2149516979: "joe" => "joe"
      reviewers.236488699:  "billy" => "billy"
      reviewers.2449433192: "bob" => "bob"
      reviewers.2468887411: "foo" => "foo"
      reviewers.3335378986: "shampoo" => "" (forces new resource)
      reviewers.3486131507: "soap" => "soap"
      reviewers.3510966834: "bar" => "bar"
      reviewers.380778529:  "glow" => "glow"
      reviewers.718298102:  "bit" => "bit"
      reviewers.801735074:  "bucket" => "bucket"
      reviewers.98717443:   "friend" => "friend"


Plan: 1 to add, 0 to change, 1 to destroy.

@ghost ghost added the size/S label Apr 22, 2019
@alucillo
Copy link
Author

@appilon any chance I can get some love on this PR? 😄


terraformReviewers := make([]string, 0, len(reviewers.Values))
decoder := json.NewDecoder(reviewersResponse.Body)
Copy link
Contributor

@cwood cwood May 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: could just do err := json.NewDecoder(reviersResponse.Body).Decode(&reviewers)

@cwood cwood merged commit f2f7bd2 into hashicorp:master May 14, 2019
@alucillo alucillo deleted the fix-default-reviewer-pagination branch September 12, 2019 22:39
padraic-padraic pushed a commit to Zensor-BE/terraform-provider-bitbucket that referenced this pull request Mar 24, 2022
padraic-padraic pushed a commit to Zensor-BE/terraform-provider-bitbucket that referenced this pull request Mar 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants