Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: github_repository template include_all_branches = true not applying correctly #2130

Open
1 task done
cclaes-dsi opened this issue Feb 7, 2024 · 2 comments · May be fixed by #2237
Open
1 task done

[BUG]: github_repository template include_all_branches = true not applying correctly #2130

cclaes-dsi opened this issue Feb 7, 2024 · 2 comments · May be fixed by #2237
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented

Comments

@cclaes-dsi
Copy link

cclaes-dsi commented Feb 7, 2024

Expected Behavior

The repository based on the template should be created and include all the branches from the template. A second apply should not change anything when there haven't been any changes.

Actual Behavior

The repository is created successfully (with all the branches), but during a second apply it will change include_all_branches = false -> true while it was never set to false.

Terraform Version

Terraform v1.6.6 on darwin_amd64

  • provider registry.terraform.io/integrations/github v5.45.0

Affected Resource(s)

  • github_repository

Terraform Configuration Files

resource "github_repository" "this" {
  allow_auto_merge          = false
  allow_rebase_merge        = false
  allow_squash_merge        = false
  allow_update_branch       = false
  auto_init                 = true
  delete_branch_on_merge    = true
  description               = var.description
  merge_commit_message      = "PR_TITLE"
  merge_commit_title        = "MERGE_MESSAGE"
  name                      = var.name

  template {
    include_all_branches = true
    owner                = var.organization
    repository           = var.create_development_branch ? "template-dev" : "template-main"
  }
}

Steps to Reproduce

Create a repository that is based on a template with include_all_branches = true, apply the resource. Apply again and it will suggest changing include_all_branches = false -> true

Debug Output

# First apply  
resource "github_repository" "this" {
.....
      + template {
          + include_all_branches = true
          + owner                = "XXX"
          + repository           = "template-main"
        }
    }

# Second apply without making any changes
~ resource "github_repository" "this" {
        id                          = "template-test-main"
        name                        = "template-test-main"
        # (33 unchanged attributes hidden)

      ~ template {
          ~ include_all_branches = false -> true
            # (2 unchanged attributes hidden)
        }

        # (1 unchanged block hidden)
    }

Panic Output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@cclaes-dsi cclaes-dsi added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Feb 7, 2024
@cclaes-dsi
Copy link
Author

This has been tested by setting auto_init = false as well, but it had the same result.

@kfcampbell kfcampbell added Status: Up for grabs Issues that are ready to be worked on by anyone and removed Status: Triage This is being looked at and prioritized labels Feb 12, 2024
@ethanrucinski
Copy link

I've proposed a solution to this in my PR. I don't believe the GitHub API allows retrieving this value from an existing GitHub repository. I proposed simply persisting the provided value from the template into state as it cannot be updated on or retrieved from an existing repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Up for grabs Issues that are ready to be worked on by anyone Type: Bug Something isn't working as documented
Projects
None yet
3 participants