warrensbox/terraform-switcher

Re-add support for environment variable that is a default version

Closed this issue · 0 comments

We used to set TF_VERSION env variable and used this as the fallback (in fact, this is how my projects Terrareg/Terrarun use it).
Now, however, it's the highest priority (excluding CMD arguments)!
Since, historically, the env variable was really treated as overriding the default-version argument, not the actual version flag.
I guess this was broken in the main parameters refactoring (a couple of releases ago) (https://github.com/warrensbox/terraform-switcher/pull/356/files#diff-2873f79a86c0d8b3335cd7731b0ecf7dd4301eb19a82ef7a1cba7589b5252261L149)

I think the correct answer, is to add a new env variable for TF_DEFAULT_VERSION and maybe TOML config for this, which will override the params.DefaultVersion...
I think we'd need to check params.Version at the end of populateParams and, if empty, set to DefaultVersion.