jdamata / terraform-provider-sonarqube

Terraform provider for managing Sonarqube configuration
GNU General Public License v3.0
62 stars 50 forks source link

Error in set up project's main branch #257

Open Malgosiatobiasz1 opened 2 months ago

Malgosiatobiasz1 commented 2 months ago

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`
freeranger commented 2 months ago

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)