mirror of
https://github.com/hashicorp/setup-terraform.git
synced 2025-12-17 17:02:36 +00:00
Use $RUNNER_TEMP when TF_CLI_CONFIG_FILE not in use
If you don't specify the TF_CLI_CONFIG_FILE environment variable, the default config is written to $HOME directory, which could theoretically be shared by multiple runners when using self-hosted runners. When TF_CLI_CONFIG_FILE is _not_ in use, I replaced the usage of $HOME with the directory $RUNNER_TEMP, whose setup/cleanup is managed by the runner framework and exported a TF_CLI_CONFIG_FILE.
This commit is contained in:
parent
633666f66e
commit
c9de504a6e
4 changed files with 44 additions and 70 deletions
16
dist/index.js
vendored
16
dist/index.js
vendored
|
|
@ -103,15 +103,15 @@ credentials "${credentialsHostname}" {
|
|||
}`.trim();
|
||||
// eslint-enable
|
||||
|
||||
// default to OS-specific path
|
||||
let credsFile = osPlat === 'win32'
|
||||
? `${process.env.APPDATA}/terraform.rc`
|
||||
: `${process.env.HOME}/.terraformrc`;
|
||||
// set or use the TF_CLI_CONFIG_FILE environment variable
|
||||
let credsFile = process.env.TF_CLI_CONFIG_FILE;
|
||||
if (!credsFile) {
|
||||
credsFile = path.join(process.env.RUNNER_TEMP, 'setup-terraform.tfrc');
|
||||
core.debug(`Default CLI config created as ${credsFile}`);
|
||||
core.exportVariable('TF_CLI_CONFIG_FILE', credsFile);
|
||||
}
|
||||
|
||||
// override with TF_CLI_CONFIG_FILE environment variable
|
||||
credsFile = process.env.TF_CLI_CONFIG_FILE ? process.env.TF_CLI_CONFIG_FILE : credsFile;
|
||||
|
||||
// get containing folder
|
||||
// create containing folder in case it doesn't exist
|
||||
const credsFolder = path.dirname(credsFile);
|
||||
|
||||
core.debug(`Creating ${credsFolder}`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue