terraform-switcher
terraform-switcher copied to clipboard
feat: allow to show required by module version explicitly
Proposed changes simplify the possibility to use tfswitch
in automation: my own use-case is to fetch the required by project terraform version and to use specific version of docker image with terraform inside the CI/CD pipeline.
Related diagnostic messages has been moved to stderr
to allow output to be fetched like
$ echo "Version required by module: $(go run main.go --chdir ~/foo/ --show-latest-required)"
Reading required version from terraform file
Reading required version from constraint: ~> 1.4.0, < 1.4.5
Matched version: 1.4.4
Version required by module: 1.4.4
Somewhat alike use case that I created issue two years ago for: https://github.com/warrensbox/terraform-switcher/issues/154
- This feature might probably need to be reflected in README
- New cmdline arg should be covered with test(s) if possible please
- This works oddly on my end:
But seems any "--show-*" flag works in a same way when there is a .toml file provided
case fileExists(TOMLConfigFile) || fileExists(HomeTOMLConfigFile):
in that case there is no --show flag check at all.
- This works oddly on my end:
But seems any "--show-*" flag works in a same way when there is a .toml file provided
case fileExists(TOMLConfigFile) || fileExists(HomeTOMLConfigFile):
in that case there is no --show flag check at all.
Oh, good catch. I missed this behavior =( Could you probably file an issue for this to get fixed (so that --show*
flags don't actually switch TF version)? Thanks.
@warrensbox @jukie Any clue on whether this was implemented this way on purpose or this is indeed a bug?
Created #302 to clarify the flags logic