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

[WIP] Add graceful fail for min-required #365

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JeanFred
Copy link

Even when setting TFENV_TERRAFORM_VERSION to min-required, we might prefer to fallback on the normal inference method rather than a hard fail.

Resolves #353

Even when setting `TFENV_TERRAFORM_VERSION` to `min-required`,
we might prefer to fallback on the normal inference method
rather than a hard fail.

Resolves tfutils#353
@JeanFred
Copy link
Author

JeanFred commented Oct 25, 2022

I’m floating this a fairly naive (and maybe not desirable) solution to #353. It does work fine, although the recursive call to tfenv-version-name might not be the most elegant solution. I mean this as a conversation starter :)

@JeanFred
Copy link
Author

Sample output:
TFENV_DEBUG=1 TFENV_TERRAFORM_VERSION='min-required' /.tfenv/bin/terraform --version

[DEBUG] Sourcing helpers from /.tfenv/lib/helpers.sh
DEBUG trap set
Helpers sourced successfully
$PATH does not contain '/.tfenv/libexec', prepending and exporting it now
$PATH does not contain '/.tfenv/bin', prepending and exporting it now
program="terraform"
Getting version from tfenv-version-name
TFENV_VERSION specified in TFENV_TERRAFORM_VERSION environment variable: min-required
TFENV_VERSION uses min-required keyword, looking for a required_version in the code
Appropriate required_version not found, skipping min-required
Specifically asked for min-required via terraform{required_version}, but none found, continuing
We are not hardcoded by a TFENV_TERRAFORM_VERSION environment variable
Looking for a version file in /code/x/y
Not found at /code/x/y/.terraform-version
Not found at /code/x/.terraform-version
Found at /code/.terraform-version
TFENV_VERSION_FILE retrieved from tfenv-version-file: /code/.terraform-version
TFENV_VERSION specified in TFENV_VERSION_FILE: 0.12.31
TFENV_VERSION does not use "latest" keyword
TFENV_VERSION does not use "latest" keyword
Appropriate required_version not found, skipping min-required
TFENV_VERSION is 0.12.31
TF_BIN_PATH added to PATH: /.tfenv/versions/0.12.31/terraform
Executing: /.tfenv/versions/0.12.31/terraform --version
Terraform v0.12.31

@JeanFred
Copy link
Author

Is there any interest in this proposed change? :)

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

Successfully merging this pull request may close these issues.

min-required and fallback
1 participant