jdamata/terraform-provider-sonarqube

Error in set up project's main branch

Closed this issue · 2 comments

Terraform Version

1.4.6

Affected Resource(s)

sonarqube_project_main_branch

Terraform Configuration Files

inputs = {
  name    = "dev"
  project = "project_key"
}
resource "sonarqube_project_main_branch" "branch" {
  for_each = var.branch
  name     = each.value.inputs.name
  project  = each.value.inputs.project
}

### Expected Behavior
"dev" branch will be set up as the project's main branch

### Actual Behavior
What actually happened?

│ Error: API returned an error: Impossible to update branch name: a branch with name "dev" already exists in the project.
│ 
│   with sonarqube_project_main_branch.branch["testxml_main_branch/testxml_main_branch.hcl"],
│   on project_main_branch.tf line 1, in resource "sonarqube_project_main_branch" "branch":1: resource "sonarqube_project_main_branch" "branch" {

### Steps to Reproduce
1.Project in sonarqube instance with 2 branches : main and dev
2. I want to set up dev branch as the project's main branch 
3. `terragrunt apply`

Hi
The sonarqube_project_main_branch resource only supports creating and managing the main branch: https://github.com/jdamata/terraform-provider-sonarqube/blob/master/docs/resources/sonarqube_project_main_branch.md
Essentially you want to switch it to a different existing branch.
It would need some thought on how to support both use cases, either with the same resource or a completely different one.
Feel free to submit a proposal (or indeed a PR to implement an idea)

closing due to inactivity