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

default_branch updates not reflected in UI #715

Closed
mallyvai opened this issue Mar 2, 2021 · 2 comments · Fixed by #719
Closed

default_branch updates not reflected in UI #715

mallyvai opened this issue Mar 2, 2021 · 2 comments · Fixed by #719

Comments

@mallyvai
Copy link

mallyvai commented Mar 2, 2021

Description of bug

Whenever we try and modify the default_branch using the github-tf provider, it doesn't actually perform the update and we have to go to the UI.

It looks like there's a similar issue reported (and troubleshooted) here: google/go-github#1578

Terraform Version

apt-get install -y terraform=0.14.4

  required_providers {
    github = {
      version = "~> 4.2.0"
      source  = "integrations/github"
    }

Affected Resource(s)

Please list the resources as a list, for example:

  • github_repository

Terraform Configuration Files

resource "github_repository" "checkout-service" {
  name        = "checkout-service"
  description = lookup(var.repo_monolith.checkout-service, "description", null)

  private = true

  allow_merge_commit     = lookup(lookup(var.repo_monolith, "checkout-service", {}), "allow_merge_commit", false)
  allow_rebase_merge     = lookup(lookup(var.repo_monolith, "checkout-service", {}), "allow_rebase_merge", false)
  allow_squash_merge     = lookup(lookup(var.repo_monolith, "checkout-service", {}), "allow_squash_merge", true)
  archived               = lookup(lookup(var.repo_monolith, "checkout-service", {}), "archived", false)
  default_branch         = lookup(var.repo_monolith, "checkout-service", {})["default_branch"]
  delete_branch_on_merge = lookup(lookup(var.repo_monolith, "checkout-service", {}), "delete_branch_on_merge", true)
  has_downloads          = lookup(lookup(var.repo_monolith, "checkout-service", {}), "has_downloads", false)
  has_issues             = lookup(lookup(var.repo_monolith, "checkout-service", {}), "has_issues", false)
  has_projects           = lookup(lookup(var.repo_monolith, "checkout-service", {}), "has_projects", false)
  has_wiki               = lookup(lookup(var.repo_monolith, "checkout-service", {}), "has_wiki", false)
  vulnerability_alerts   = lookup(lookup(var.repo_monolith, "checkout-service", {}), "vulnerability_alerts", false)
  auto_init              = lookup(lookup(var.repo_monolith, "checkout-service", {}), "auto_init", false)
  homepage_url              = lookup(lookup(var.repo_monolith, "checkout-service", {}), "homepage_url", null)

  // Originally used to create repos with a starting branch. Now retained for backwards-compatability
  license_template = lookup(lookup(var.repo_monolith, "checkout-service", {}), "license_template", null)

  // Pages not supported yet
  lifecycle {
    ignore_changes = [
      pages,
    ]
  }
}

#### in variables.tf
[...]
    checkout-service = {
    
    default_branch = "master"
    
    description = "Checkout service"
    
    }

Debug Output

Please provide a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist.

Panic Output

If Terraform produced a panic, please provide a link to a GitHub Gist containing the output of the crash.log.

Expected Behavior

What should have happened?

Actual Behavior

What actually happened?

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. Create a repository with a default branch name of master. Add some commits to it .
  2. Change the Terraform definition of the repo to change the default_branch to main.
    3.terraform plan and then terraform apply. This should succeed.
  3. Go to the Github UI for the repo
  4. You'll notice the default_branch is still master

Important Factoids

Standard Github Enterprise account. Terraform is running in usual combination of EC2 + DynamoDB + S3

@tibbes
Copy link
Contributor

tibbes commented Mar 4, 2021

Thanks for the report @mallyvai. I've validated it and submitted a fix (#719). Once that is merged you would have to wait for the next release to benefit from the fix.

However, the default_branch argument to github_repository is deprecated in any case. Its replacement is the github_default_branch resource, which is not affected by the bug you reported (although I do see there have been fixes to it since 4.2.0, so I recommend you upgrade to the latest released version of the Terraform GitHub Provider). You could migrate to that straight away if you wish.

@mallyvai
Copy link
Author

mallyvai commented Mar 5, 2021

You're a champ @tibbes ! Thanks for the fix and the explanation. We'll plan a change to the latest version of the provider ASAP when it releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants