The problem is that by the time it hits this code, we have already read the resp.Body so this is alway empty.
In versions of Sonar prior to 9.9 this was not an issue because no conditions are added when the quality gate is created.
In 9.9 and above however, six conditions are automatically added and so they should be returned here.
Terraform Version
Terraform v1.3.9
Affected Resource(s)
Please list the resources as a list, for example: sonarqube_qualitygate`
Expected Behavior
< 9.9 - no conditions are populated - e.g.
resource "sonarqube_qualitygate" "default" {
conditions = []
id = "My way"
is_default = true
name = "My way"
}
9.9+ - 6 conditions populated - e.g.
resource "sonarqube_qualitygate" "default" {
conditions = [
<snip>
{
error = "80"
id = "AYe40uWkpq_IgwDfAktH"
metric = "new_coverage"
op = "LT"
},
]
id = "My way"
is_default = true
name = "My way"
}
Actual Behavior
In all cases we get
resource "sonarqube_qualitygate" "default" {
conditions = []
id = "My way"
is_default = true
name = "My way"
}
Steps to Reproduce
With a terraform script like this:
resource "sonarqube_qualitygate" "default" {
name = "My way"
}
Hi
The
sonarqube_qualitygate
resource looks like it should populateconditions
when the resource is read - see here: https://github.com/jdamata/terraform-provider-sonarqube/blob/e230cdf842cf6a0beaf46419903d8d0ed8e8ef52/sonarqube/resource_sonarqube_qualitygate.go#L182-L186The problem is that by the time it hits this code, we have already read the
resp.Body
so this is alway empty.In versions of Sonar prior to
9.9
this was not an issue because no conditions are added when the quality gate is created. In9.9
and above however, six conditions are automatically added and so they should be returned here.Terraform Version
Terraform v1.3.9
Affected Resource(s)
Please list the resources as a list, for example:
sonarqube_qualitygate`Expected Behavior
< 9.9
- no conditions are populated - e.g.9.9+
- 6 conditions populated - e.g.Actual Behavior
In all cases we get
Steps to Reproduce
With a terraform script like this:
apply it to a Sonar instance
9.9
or aboveReferences
https://github.com/jdamata/terraform-provider-sonarqube/issues/154 refers to the problem but I think fixing the problem does not depend on that and may well form part of the solution to same