Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

sonarcloud_quality_gate_selection is broken when the selection contains more than 99 project_keys #137

Open
kiuby opened this issue Mar 10, 2023 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@kiuby
Copy link

kiuby commented Mar 10, 2023

Description

Right now, we can't create a quality gate selection which contains more than 99 projects due to the pagination.

Affected Resource(s)

  • sonarcloud_quality_gate_selection

Terraform Configuration Files

resource "sonarcloud_quality_gate_selection" "my_quality_gate_selection" {
  gate_id = sonarcloud_quality_gate.my_quality_gate.gate_id
  # it should contains more than 99 projects
  project_keys = [ "xx", "yy", ...]
}

Expected Behavior

We should be able to create a quality gate selection with more than 99 projects.

Actual Behavior

The creation is working, but the apply is failing just after (when it tried to retrieve the list from sonarcloud api after the creation)

Steps to Reproduce

Create a sonarcloud_quality_gate_selection with more than 99 project_keys, and apply it.

References

Error during the apply:

 Error: Could not find Quality Gate Selection
│
│   with sonarcloud_quality_gate_selection.my_quality_gate_selection
│   on main.tf line 331, in resource "sonarcloud_quality_gate_selection" "my_quality_gate_selection":
│  331: resource "sonarcloud_quality_gate_selection" "my_quality_gate_selection" {
│
|  The findSelection function was unable to find the project keys:  [...]
| in the response: &{Paging:{PageIndex:1 PageSize:100 Total:144}
  • #0000
@kiuby kiuby added the bug Something isn't working label Mar 10, 2023
@reinoudk
Copy link
Contributor

Hi @kiuby, I didn't have time to look at this yet but I'll have a look somewhere this week. I'd have expected a SearchAll method to be available to handle pagination, but somehow it has not been generated.

@reinoudk reinoudk added this to the v0.5.3 milestone Apr 27, 2023
@reinoudk
Copy link
Contributor

The SearchAll method is not being generated because the SonarCloud API is using different parameter names for paging, i.e. p / ps and page/ pageSize (which is just crazy if you ask me). I'll have to add support for this in go-sonarcloud, which might be a bit iffy without making that even more of a ball of spaghetti..

I'll post an update here when that's been implemented. I've added this issue to the v0.5.3 milestone though, cause it should be fixed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants