Repository navigation
fix: preserve existing Terraform CLI config - #571
Open
Arjunmehta312 wants to merge 1 commit into
Open
Arjunmehta312 wants to merge 1 commit into
Arjunmehta312 wants to merge 1 commit into
Conversation
addCredentials() used fs.writeFile() and overwrote any existing Terraform CLI configuration file, destroying user configuration such as plugin_cache_dir, provider mirrors, and other credentials blocks. The existing content is now preserved and the credentials block is appended only when the target hostname has no credentials block yet; an existing block for the hostname is left untouched. Fixes hashicorp#428
Author
|
Hi @rainkwan , whenever you have a chance, I’d really appreciate your review. Thanks! |
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was broken
addCredentials()inlib/setup-terraform.jsusedfs.writeFile()to write the credentials block, overwriting any pre-existing Terraform CLI configuration file (~/.terraformrc,%APPDATA%/terraform.rc, or the path set viaTF_CLI_CONFIG_FILE). Existingplugin_cache_dir, provider mirrors, other credentials blocks, and any other user configuration were silently destroyed.See #428 and #269.
What changed
ENOENTis treated as "file does not exist"; all other read errors are propagated.Validation
npm test(semistandard + jest): 21/21 passingTF_CLI_CONFIG_FILEoverridenpm run build;dist/index.jsregenerated (required by check-dist).changes/unreleased/Note
If credentials for the same hostname already exist, the supplied token is not applied; delete the block/file to re-provision credentials.