You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TFLint plugins are primarily intended to be hosted on github.com and is installed using the GitHub API.
Currently, we support authenticated requests with GITHUB_TOKEN for the following purposes:
Apart from this, plugins can also be hosted on GitHub Enterprise Server (GHES). See #1751
The problem is that since both github.com and GHES use the same GITHUB_TOKEN, there is no way to install a plugin hosted on both at once as an authenticated request. See also #2004
Proposal
Add access_token_env as an attribute of the plugin block.
Plugins with access_token_env set refer to the declared environment variable instead of GITHUB_TOKEN when sending authenticated requests. We'll probably need to change the code below:
Perhaps this is a minimal change, but I'm still not sure if this is the ideal interface. We may need to extend the source attribute to object, or new concepts like the connection block, or an authentication mechanism other than environment variables.
EDIT:@bendrucker suggests a way to provide per-host environment variables like TFE #2005 (comment). I prefer this suggestion as it is better than extending the existing syntax.
Adding configuration to the plugin block creates a need for repetition and an opportunity for divergence. The real use case here is to provide different tokens per plugin host, not necessarily per plugin.
Terraform does this with environment variables where the variable name is suffixed with the domain, with . replaced with _.
This should work here without having to touch any interfaces. If an env var isn't set for GITHUB_TOKEN_${sanitized_host} then it can fall back to plain GITHUB_TOKEN. So for example GITHUB_TOKEN_github_com would be equivalent to setting GITHUB_TOKEN for github.com users.
Great suggestion. I was going to look up how other services solved similar issues, but I couldn't find it, so thank you for your help.
I also think it's better to be able to set per-host environment variables than to extend the existing syntax.
Introduction
TFLint plugins are primarily intended to be hosted on github.com and is installed using the GitHub API.
Currently, we support authenticated requests with
GITHUB_TOKEN
for the following purposes:https://github.com/terraform-linters/tflint/blob/v0.50.3/docs/user-guide/plugins.md#avoiding-rate-limiting
Apart from this, plugins can also be hosted on GitHub Enterprise Server (GHES). See #1751
The problem is that since both github.com and GHES use the same
GITHUB_TOKEN
, there is no way to install a plugin hosted on both at once as an authenticated request. See also #2004Proposal
Add
access_token_env
as an attribute of theplugin
block.Plugins with
access_token_env
set refer to the declared environment variable instead ofGITHUB_TOKEN
when sending authenticated requests. We'll probably need to change the code below:tflint/plugin/install.go
Lines 253 to 259 in 9bad280
Perhaps this is a minimal change, but I'm still not sure if this is the ideal interface. We may need to extend the
source
attribute to object, or new concepts like theconnection
block, or an authentication mechanism other than environment variables.EDIT: @bendrucker suggests a way to provide per-host environment variables like TFE #2005 (comment). I prefer this suggestion as it is better than extending the existing syntax.
We may be able to use something like terraform-svchost to normalize hostnames.
https://github.com/hashicorp/terraform/blob/v1.5.7/internal/command/cliconfig/credentials.go#L120
References
The text was updated successfully, but these errors were encountered: