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

Permissions/compatibility for github_repository_autolink_reference and more #986

Closed
mengesb opened this issue Nov 25, 2021 · 3 comments
Closed
Labels
r/repository_autolink_reference Status: Stale Used by stalebot to clean house Status: Up for grabs Issues that are ready to be worked on by anyone Type: Feature New feature or request

Comments

@mengesb
Copy link

mengesb commented Nov 25, 2021

Terraform Version

Terraform v1.0.11
on darwin_amd64
+ provider registry.terraform.io/integrations/github v4.18.0

Affected Resource(s)

  • github_repository_autolink_reference
  • Others ... see factoids

Terraform Configuration Files

locals {
    autolink = var.autolink_url == null ? {} : { for i in var.autolink : i => "${trimsuffix(var.autolink_url, "/")}/${i}-<num>" }
}

resource "github_repository_autolink_reference" "autolink" {
  for_each            = local.autolink
  repository          = github_repository.repository.name
  key_prefix          = "${each.key}-"
  target_url_template = each.value
}

Debug Output

│ Error: POST https://api.github.com/repos/${GITHUB_USER}/___repo___/autolinks: 404 Not Found []
│ 
│   with module.test_repo_github.github_repository_autolink_reference.autolink["TICKET"],
│   on modules/terraform-github-repository/main.tf line 66, in resource "github_repository_autolink_reference" "autolink":
│   66: resource "github_repository_autolink_reference" "autolink" {

Panic Output

N/A

Expected Behavior

More friendly message if possible - this was a permissions issue, not a 404 Not Found issue

Actual Behavior

HTTP/404 returned due to PAT not having all repo permissions

Steps to Reproduce

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

  1. Create a personal access token without all repo permissions
  2. terraform apply

Important Factoids

I'm unsure if this is possible, but there are a couple of improvements that would be nice.

In the event that the user specifies a base_url that isn't api.github.com, it likely means that the user is talking to a GHES system. Certain resources, namely this resource, isn't available until GHES 3.3. I'm not sure if there's an ability to report on compatibility along two things

  • For each resource, list the relative permissions required
  • For each resource, list the minimum GHES API and GH API version requirement? Perhaps the GH API version requirement isn't necessary, but in the case of GHES, this does matter.

References

@mengesb
Copy link
Author

mengesb commented Nov 25, 2021

Unsure if this helps much for reference:

https://docs.github.com/en/enterprise-server@2.22/rest/reference/meta#get-github-enterprise-server-meta-information

When I did for a data source was something to the effect of:

data "http" "GHES" {
  url = "https://${var.base_url}/api/v3/meta"

  request_headers = {
    Accept = "application/vnd.github.v3+json"
  }
}

output "ghes_version" {
  value = jsondecode(data.http.GHES.body).installed_version
}

This returns

~ $ terraform console
> module.test_repo_ghes.ghes_version
"2.22.6"

@jcudit jcudit added Type: Feature New feature or request r/repository_autolink_reference Type: Bug Something isn't working as documented and removed Type: Feature New feature or request labels Jan 5, 2022
@github-actions
Copy link

👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!

@github-actions github-actions bot added the Stale label Nov 30, 2022
@nickfloyd nickfloyd added Status: Stale Used by stalebot to clean house and removed Stale labels Nov 30, 2022
@kfcampbell kfcampbell added Type: Feature New feature or request Status: Up for grabs Issues that are ready to be worked on by anyone Priority: Normal and removed Type: Bug Something isn't working as documented labels Dec 1, 2022
@github-actions github-actions bot removed the Status: Stale Used by stalebot to clean house label Dec 1, 2022
Copy link

👋 Hey Friends, this issue has been automatically marked as stale because it has no recent activity. It will be closed if no further activity occurs. Please add the Status: Pinned label if you feel that this issue needs to remain open/active. Thank you for your contributions and help in keeping things tidy!

@github-actions github-actions bot added the Status: Stale Used by stalebot to clean house label Apr 21, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
r/repository_autolink_reference Status: Stale Used by stalebot to clean house Status: Up for grabs Issues that are ready to be worked on by anyone Type: Feature New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants