DrFaust92 / terraform-provider-bitbucket

Terraform Bitbucket Cloud provider.
https://registry.terraform.io/providers/drfaust92/bitbucket
Mozilla Public License 2.0
36 stars 29 forks source link

v2.33.0 breaks support of more than 10 deployment variables #164

Closed zhemaituk closed 8 months ago

zhemaituk commented 1 year ago

Terraform Version

Terraform v1.4.6
on darwin_arm64
+ provider registry.terraform.io/cyrilgdn/postgresql v1.19.0
+ provider registry.terraform.io/drfaust92/bitbucket v2.33.0
+ provider registry.terraform.io/franckverrot/stripe v1.9.0
+ provider registry.terraform.io/hashicorp/aws v4.67.0
+ provider registry.terraform.io/hashicorp/cloudinit v2.3.2
+ provider registry.terraform.io/hashicorp/dns v3.3.2
+ provider registry.terraform.io/hashicorp/external v2.3.1
+ provider registry.terraform.io/hashicorp/local v2.4.0
+ provider registry.terraform.io/hashicorp/random v3.5.1
+ provider registry.terraform.io/hashicorp/tls v4.0.4

Affected Resource(s)

Terraform Configuration Files

    bitbucket = {
      source = "DrFaust92/bitbucket"
      version = "2.33.0"
    }
...
19 times:
    resource "bitbucket_deployment_variable" "name"

Expected Behavior

19 deployment variables are created just once.

Actual Behavior

Every time 9 variables appear in terraform plan, even though the variables already exist, creation fails as variable already exist.

Workaround

Downgrade to 2.32.0.

References

zhemaituk commented 1 year ago

Possibly related to removed pagelen param from: https://github.com/DrFaust92/bitbucket-go-client/commit/95bee263c230f5ae4f44846789e346521897cbaf#diff-2dfbd21797419725369cf212d25a1ab3fb87f927904559673880d359c0497f1dL1693

zhemaituk commented 1 year ago

cc: @DrFaust92

DrFaust92 commented 1 year ago

zhemaituk Ill try to take a look soon

opencii commented 8 months ago

The problem is that in https://github.com/DrFaust92/terraform-provider-bitbucket/blob/master/bitbucket/resource_deployment_variable.go#L108 the code would need to iterate over all pages by examining rvRes.Next and incrementing the Page attribute of the PipelinesApiGetDeploymentVariablesOpts argument to GetDeploymentVariables() to collect rvRes.Values from all pages. That would be the least invasive solution I guess. The documentation on the next field in the Bitbucket API response (https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pipelines/#api-repositories-workspace-repo-slug-deployments-config-environments-environment-uuid-variables-get) suggest using the raw URL from it instead of consturcting your own next-page URLs, but that would necessitate making changes to bitbucket-client-go.

zhemaituk commented 8 months ago

Iterating would be ideal. But even simply adding ?pagelen=100 would address most of the practical cases.

DrFaust92 commented 8 months ago

I’ll check and get to patch quickly

On Thu, 2 Nov 2023 at 16:59 Andrei Zhemaituk @.***> wrote:

Iterating would be ideal. But even simply adding ?pagelen=100 would address most of the practical cases.

— Reply to this email directly, view it on GitHub https://github.com/DrFaust92/terraform-provider-bitbucket/issues/164#issuecomment-1790900879, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIA2W7TTKYPIZLW3EG7BP23YCOYOHAVCNFSM6AAAAAAYF547FWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJQHEYDAOBXHE . You are receiving this because you were mentioned.Message ID: @.***>

DrFaust92 commented 8 months ago

added to 2.37.2, please check

zhemaituk commented 8 months ago

Thanks @DrFaust92 , 2.37.2 works like a charm.