Skip to content

Commit

Permalink
feat(cli): Introduce optional CDKTF_GITHUB_API_TOKEN env var to use f…
Browse files Browse the repository at this point in the history
…or authenticated requests when determining available pre-built providers for Go
  • Loading branch information
ansgarm committed Dec 14, 2022
1 parent 9a21a46 commit 7f9efc7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ jobs:
env:
CHECKPOINT_DISABLE: "1"
TERRAFORM_VERSION: ${{ matrix.terraform }}
CDKTF_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
timeout-minutes: 60

steps:
Expand Down Expand Up @@ -128,6 +129,7 @@ jobs:
env:
CHECKPOINT_DISABLE: "1"
TERRAFORM_VERSION: ${{ matrix.terraform }}
CDKTF_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
timeout-minutes: 60

steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import * as semver from "semver";
import fetch from "node-fetch";
import * as z from "zod";

const { CDKTF_GITHUB_API_TOKEN } = process.env;

// {
// "version": "1.0.0",
// "name": "testUSHasF",
Expand Down Expand Up @@ -670,6 +672,10 @@ class GoPackageManager extends PackageManager {
const response = await fetch(url, {
headers: {
Accept: "application/vnd.github+json",
"User-Agent": "HashiCorp/cdktf-cli",
...(CDKTF_GITHUB_API_TOKEN
? { Authorization: `Bearer ${CDKTF_GITHUB_API_TOKEN}` }
: {}),
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Use these environment variables to configure CDK for Terraform (CDKTF) behavior.
| Variable Name | Description | Default |
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- |
| CDKTF_DISABLE_PLUGIN_CACHE_ENV | If set to `true` or `1`, CDKTF disables the [plugin cache](/cli/config/config-file#provider-plugin-cache). Otherwise, CDKTF creates the plugin cache directory in `~/.terraform.d/plugin-cache` if it is not already present. | |
| CDKTF_GITHUB_API_TOKEN | If set, the `provider add` and `provider update` command will use this token for authenticated requests to Github when looking for pre-built provider packages for Go. | |
| CDKTF_HOME | Where CDKTF should store cache and configuration files. | `~/.cdktf` |
| CDKTF_LOG_FILE_DIRECTORY | The directory path where CDKTF should create `cdktf.log` and print logs at the `debug` level. If not set, CDKTF writes logs to standard out at the level specified in `CDKTF_LOG_LEVEL`. | standard out |
| CDKTF_LOG_LEVEL | Controls how much log information CDKTF prints to the console. You can set it to one of the following values: `all`, `debug`, `info`, `warn`, `error`, `fatal`, `off`. | `warn` |
Expand Down

0 comments on commit 7f9efc7

Please sign in to comment.