terraform-provider-sonarqube
terraform-provider-sonarqube copied to clipboard
Import sonarqube_group for paginated entries
Hello @jdamata,
I found a bug while importing a sonarqube group, which isn't delivered via the sonarqube API (/api/user_groups/search?q=) on the first page. Sonarqube paginates results and the terraform provider doesn't browse "pages" in order to find the group.
Terraform Version
$ terraform -v
Terraform v1.0.1
on darwin_amd64
+ provider registry.terraform.io/jdamata/sonarqube v0.0.6
Affected Resource(s)
- sonarqube_group
- maybe more... I haven't tested, but I can imagine it affects all paginated resources
Example GIST
https://gist.github.com/scurow-bdr/9d38c438028de7d0c69e17376ec2914b
Expected Behavior
The provider should recognize paginated entries while importing.
Actual Behavior
The provider does not find paginated entries while importing.
Steps to Reproduce
Please list the steps required to reproduce the issue, for example:
./run.shin the aforementioned GIST https://gist.github.com/scurow-bdr/9d38c438028de7d0c69e17376ec2914b
This is present for projects as well.
I have 119 projects currently loaded into my sonarqube instance and the provider fails on retrieving their statuses.
This is present for projects as well.
I have 119 projects currently loaded into my sonarqube instance and the provider fails on retrieving their statuses.
I think for projects this can be somewhat fixed by increasing page size with ps query parameter in https://github.com/jdamata/terraform-provider-sonarqube/blob/master/sonarqube/resource_sonarqube_project.go#L111 if implementing pagination is difficult. Similar query parameter can be added to https://github.com/jdamata/terraform-provider-sonarqube/blob/master/sonarqube/resource_sonarqube_group.go#L96 . Maximum number of entries is 500
This is present for projects as well. I have 119 projects currently loaded into my sonarqube instance and the provider fails on retrieving their statuses.
I think for projects this can be somewhat fixed by increasing page size with
psquery parameter in https://github.com/jdamata/terraform-provider-sonarqube/blob/master/sonarqube/resource_sonarqube_project.go#L111 if implementing pagination is difficult. Similar query parameter can be added to https://github.com/jdamata/terraform-provider-sonarqube/blob/master/sonarqube/resource_sonarqube_group.go#L96 . Maximum number of entries is 500
Pagination shouldn't be too difficult to implement. I just haven't had the time to look into this. If you wanted to open a PR to hardcode the ps parameter to 500 for projects, i would be ok approving/merging that until we get pagination going