Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let .terraform-version have comments with a # #391

Open
isybub opened this issue Apr 19, 2023 · 1 comment
Open

Let .terraform-version have comments with a # #391

isybub opened this issue Apr 19, 2023 · 1 comment

Comments

@isybub
Copy link

isybub commented Apr 19, 2023

I made a branch and tried to make a PR but I can't find contribution guidelines so I don't think I can push to the remote.
All it is is changing line 13 in lib/tfenv-version-name.sh
from
TFENV_VERSION="$cat "${TFENV_VERSION_FILE}" || true)"
to
TFENV_VERSION="$(sed -e '/^#/d' "${TFENV_VERSION_FILE}" || true)" \

This also strips blank lines.

@jmnavarrol
Copy link

An alternate, maybe easier and less prone to side effects, approach would be to completely ditch .terraform-version file. See #367 for a happy path.

Then:

  • If TFENV_AUTO_INSTALL=true:
    • Is there a version requested on Terraform source code? Honor it, maybe with the help of TFENV_TERRAFORM_VERSION's value min-allowed / latest-allowed.
    • When Terraform source code doesn't hint a version, honor TFENV_TERRAFORM_VERSION. If TFENV_TERRAFORM_VERSION is not set, consider its default value to be latest-allowed.
  • If TFENV_AUTO_INSTALL=false, do nothing.

This way, just using tfenv on its default configuration will render the expected results: Terraform ends up installed and working on the highest valid version (either latest stable or the highest one as per Terraform's code constrains).

Also you can avoid tfenv automatically installing terraform as per TFENV_AUTO_INSTALL=false.
Also you can change tfenv's default version management behaviour by means of TFENV_TERRAFORM_VERSION=min-allowed.
Also you could set TFENV_TERRAFORM_VERSION to an explicit version (this usage should be discouraged: use Terraform's own required_version parameter for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants