warrensbox/terraform-switcher

Please respect XDG spec for config storage

Closed this issue ยท 2 comments

The XDG spec defines where config and cache files should be placed.

https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

Instead of writing to $HOME, the terraform switcher config directory should be $XDG_CONFIG_HOME/tfswitch. And the correct location for different terraform versions should be $XDG_CACHE_HOME/tfswitch.

I can implement this logic for the next release:
If $XDG_CONFIG_HOME is either not set or empty, a default equal to $HOME/.config should be used.

@warrensbox Sounds good.

Only $XDG_CONFIG_HOME or also $XDG_CACHE_HOME? E.g.:

$XDG_CACHE_HOME/tfswitch/terraform.versions

Currently the different Terraform versions are stored like that on macOS:

โ†ช tree ~/.terraform.versions/
/Users/tim/.terraform.versions/
โ”œโ”€โ”€ RECENT
โ”œโ”€โ”€ terraform_0.11.14
โ””โ”€โ”€ terraform_0.12.25