Skip to content

Commit

Permalink
Fix finding TF credential file on windows
Browse files Browse the repository at this point in the history
This corrects the getTerraformCLIToken method to correctly find the TF credential file on Windows.
  • Loading branch information
Convez authored and jpogran committed Apr 15, 2024
1 parent 7ffd6c7 commit aa56bc5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/providers/authenticationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,14 @@ export class TerraformCloudAuthenticationProvider implements vscode.Authenticati

private async getTerraformCLIToken() {
// detect if stored auth token is present
// On windows:
// ~/AppData/Roaming/terraform.d/credentials.tfrc.json
// On others:
// ~/.terraform.d/credentials.tfrc.json
const credFilePath = path.join(os.homedir(), '.terraform.d', 'credentials.tfrc.json');
const credFilePath =
process.platform === 'win32'
? path.join(os.homedir(), 'AppData', 'Roaming', 'terraform.d', 'credentials.tfrc.json')
: path.join(os.homedir(), '.terraform.d', 'credentials.tfrc.json');
if ((await this.pathExists(credFilePath)) === false) {
vscode.window.showErrorMessage(
'Terraform credential file not found. Please login using the Terraform CLI and try again.',
Expand Down

0 comments on commit aa56bc5

Please sign in to comment.