Add a flag to return the path to the binary
Closed this issue · 5 comments
Is your feature request related to a problem? Please describe.
I'm trying to use terraform-switcher in my jenkins and I'm having problems with the symlink and setting the PATH.
Describe the solution you'd like
Add a flag to terraform-switcher that behaves like which
, I only want it to return the path to the terraform binary. In our pipeline we deploy lots of different terraform repos so we would like to use the terraform-switcher feature where it automatically determines the version of terraform from the .tf
files.
We could then do something like...
tfswitch -b some/local/dir # have it detect and install the correct terraform version
TERRAFORM_BIN = $(tfswitch which) # returns the path to the terraform that it would use to deploy
$TERRAFORM_BIN apply #or some other terraform command
Describe alternatives you've considered
ugh none really. The whole -b
thing doesnt work correctly, at least with jenkins.
Additional context
Add any other context or screenshots about the feature request here.
Removed the Template Code from the Issue for better readability
It might be that the root cause of your problem "the whole -b thing does not work" is solved with #356
Please wait for Release 1.1.0 and test again if you would be so nice.
1.1.0 should drop this week.
Given tfswitch
it directed by the user with regards to the location of the terraform
symlink for the actual binary, I'd say it is not tfswitch
to "identify" the path, but instead the user. Given the provided example:
tfswitch -b some/local/dir # have it detect and install the correct terraform version
TERRAFORM_BIN = $(tfswitch which) # returns the path to the terraform that it would use to deploy
$TERRAFORM_BIN apply #or some other terraform command
what you want to do is to add full path to some/local/dir
to the PATH
env var (as it is suggested by e.g. https://tfswitch.warrensbox.com/Quick-Start/#use-tfswitchtoml-file-for-non-admin-users-with-limited-privilege-on-their-computers) or use the path explicitly full_or_relative_path_to_some/local/dir/terraform
(tfswitch
always creates symlink with name terraform
as is designed as a drop-in replacement for plain terraform
binary).
Having said that I tbh see no use case for which
subcommand. Other collaborators may see this as a use case though 😺
I will try and re-test soon
Any news on that @shadycuz ?