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

add another method to specify github token #1090

Closed
nktks opened this issue Dec 27, 2023 · 7 comments · Fixed by #1091
Closed

add another method to specify github token #1090

nktks opened this issue Dec 27, 2023 · 7 comments · Fixed by #1091
Labels
enhancement New feature or request
Milestone

Comments

@nktks
Copy link

nktks commented Dec 27, 2023

Feature Overview

We would like to add another method to specify github token to tfcmt.

Currently, it seems tfcmt uses github token only from GITHUB_TOKEN environment variable.
https:/suzuki-shunsuke/tfcmt/blob/main/pkg/notifier/github/client.go#L74-L84
https:/suzuki-shunsuke/tfcmt/blob/main/pkg/controller/controller.go#L153
https:/suzuki-shunsuke/tfcmt/blob/main/pkg/config/config.go#L22
Since GitHubToken is ignored from yaml config, it always gets from GITHUB_TOKEN environment variable.

Why is the feature needed?

We uses GitHub Provider and it seems it always uses GITHUB_TOKEN environment variable to authenticate if env variable exists.
https://registry.terraform.io/providers/integrations/github/latest/docs#oauth--personal-access-token

Even if we specify provider using another GitHub App like below, it prioritizes to use env variable and got below error.
provider:

provider "github" {
  app_auth {
    id              = $id
    installation_id = $instration_id
    pem_file        = $pen_file
  }

  owner = "owner"
}

error:

│ Error: "app_auth": conflicts with token
│ 
│   with provider["registry.terraform.io/integrations/github"],
│   on providers.tf line 6, in provider "github":
│    6: provider "github" {

Example Code

same as Why is the feature needed?

note

No response

@nktks nktks added the enhancement New feature or request label Dec 27, 2023
@nktks nktks changed the title enable to speficy github token environment variable name add another method to specify github token Dec 27, 2023
@suzuki-shunsuke
Copy link
Owner

Thank you for your proposal.
It makes sense.

How about supporting the environment variable TFCMT_GITHUB_TOKEN?

@nktks
Copy link
Author

nktks commented Dec 27, 2023

Thanks for your response!

How about supporting the environment variable TFCMT_GITHUB_TOKEN?

Sounds great!

@suzuki-shunsuke
Copy link
Owner

@suzuki-shunsuke
Copy link
Owner

@nktks

Published a prerelease version v4.8.0-1. https:/suzuki-shunsuke/tfcmt/releases/tag/v4.8.0-1
Could you try this release?
If there is no problem, we'll release v4.8.0.

@nktks
Copy link
Author

nktks commented Dec 27, 2023

Thank you!
I'll confirm v4.8.0-1.

@nktks
Copy link
Author

nktks commented Dec 27, 2023

I confirmed in our private repo and it worked!

@suzuki-shunsuke
Copy link
Owner

Thank you!
v4.8.0 is out 🎉
https:/suzuki-shunsuke/tfcmt/releases/tag/v4.8.0

@suzuki-shunsuke suzuki-shunsuke added this to the v4.8.0 milestone Dec 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants