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

Fix finding TF credential file on windows #1735

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading