Add support for ~/.opentf.d (#22)

* Use ~/.opentf.d instead of ~/.terraform.d

Stay backwards-compatible, though.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Fix imports.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Add tests.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Use util function.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Fix windows directories.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

* Add a comment to the tests.

Signed-off-by: Jakub Martin <kubam@spacelift.io>

---------

Signed-off-by: Jakub Martin <kubam@spacelift.io>
This commit is contained in:
Kuba Martin
2023-08-21 12:38:11 +02:00
committed by GitHub
parent b9677e99c6
commit e650bab8d7
7 changed files with 93 additions and 11 deletions

View File

@@ -46,7 +46,7 @@ general syntax; see the following section for information on the meaning
of each of these settings:
```hcl
plugin_cache_dir = "$HOME/.terraform.d/plugin-cache"
plugin_cache_dir = "$HOME/.opentf.d/plugin-cache"
disable_checkpoint = true
```
@@ -301,11 +301,12 @@ method.
The set of directories Terraform can select as filesystem mirrors depends on
the operating system where you are running Terraform:
* **Windows:** `%APPDATA%/terraform.d/plugins` and `%APPDATA%/HashiCorp/Terraform/plugins`
* **Mac OS X:** `$HOME/.terraform.d/plugins`,
* **Windows:** `%APPDATA%/opentf.d/plugins`, `%APPDATA%/terraform.d/plugins` and `%APPDATA%/HashiCorp/Terraform/plugins`
* **Mac OS X:** `$HOME/.opentf.d/plugins`,
`$HOME/.terraform.d/plugins`, and
`~/Library/Application Support/io.terraform/plugins`, and
`/Library/Application Support/io.terraform/plugins`
* **Linux and other Unix-like systems**:`$HOME/.terraform.d/plugins` and
* **Linux and other Unix-like systems**:`$HOME/.opentf.d/plugins`, `$HOME/.terraform.d/plugins` and
`terraform/plugins` located within a valid
[XDG Base Directory](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)
data directory such as `$XDG_DATA_HOME/terraform/plugins`.
@@ -347,7 +348,7 @@ To enable the plugin cache, use the `plugin_cache_dir` setting in
the CLI configuration file. For example:
```hcl
plugin_cache_dir = "$HOME/.terraform.d/plugin-cache"
plugin_cache_dir = "$HOME/.opentf.d/plugin-cache"
```
This directory must already exist before Terraform will cache plugins;
@@ -363,7 +364,7 @@ variable can be used to enable caching or to override an existing cache
directory within a particular shell session:
```bash
export TF_PLUGIN_CACHE_DIR="$HOME/.terraform.d/plugin-cache"
export TF_PLUGIN_CACHE_DIR="$HOME/.opentf.d/plugin-cache"
```
When a plugin cache directory is enabled, the `terraform init` command will