feature: support XDG Base Directory Specification on Unix#38046
Open
brualan wants to merge 2 commits intohashicorp:mainfrom
Open
feature: support XDG Base Directory Specification on Unix#38046brualan wants to merge 2 commits intohashicorp:mainfrom
brualan wants to merge 2 commits intohashicorp:mainfrom
Conversation
Fall back to traditional paths if XDG config directory is not present. Add comprehensive tests covering XDG and legacy configurations.
|
Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement Learn more about why HashiCorp requires a CLA and what the CLA includes Have you signed the CLA already but the status is still pending? Recheck it. |
Contributor
|
Thanks for this submission. Please sign the CLA if you would like this to be in a reviewable state, and I will raise this PR in triage. |
Author
|
Thank you! I’ve just signed the CLA |
|
Hi @crw thanks for your work I have been waiting 8 years for XDG support. Please finish this |
Contributor
|
Apologies, I was under the impression this was getting follow-up from a maintainer. Let me kick that off now. Thanks for the bump. |
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.
This PR adds optional support for the XDG Base Directory Specification on Unix-like systems for Terraform CLI configuration files. Specifically:
$XDG_CONFIG_HOME/terraformexists (as a directory), Terraform will load:terraformrcfrom$XDG_CONFIG_HOME/terraform/terraformrc$XDG_CONFIG_HOME/terraform/terraform.d~/.terraformrc~/.terraform.dThis approach ensures full backward compatibility: existing users and automation workflows remain unaffected. Only users who explicitly create the XDG config directory (
$XDG_CONFIG_HOME/terraform) will use the new layout -- aligning with the principle of “don’t break existing setups.”The implementation leverages Go’s standard library (
os.UserConfigDir()) for correctness and avoids hardcoded paths. Comprehensive tests verify behavior under multiple scenarios:terraform/dir → legacy pathterraform/dir exists → XDG path usedThis change addresses long-standing community feedback (see issue #15389) and helps reduce dotfile clutter in
$HOME, bringing Terraform in line with modern Unix conventions.Fixes #15389
Target Release
1.15.x
Rollback Plan
Changes to Security Controls
No changes to security controls.
CHANGELOG entry