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

Add a flag to return the path to the binary #217

Closed
shadycuz opened this issue Mar 23, 2022 · 5 comments · Fixed by #356
Closed

Add a flag to return the path to the binary #217

shadycuz opened this issue Mar 23, 2022 · 5 comments · Fixed by #356
Assignees
Labels
enhancement Refactor existing code for better performance and quality

Comments

@shadycuz
Copy link

shadycuz commented Mar 23, 2022

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.

@shadycuz shadycuz added the enhancement Refactor existing code for better performance and quality label Mar 23, 2022
@MatrixCrawler
Copy link
Collaborator

Removed the Template Code from the Issue for better readability

@MatrixCrawler
Copy link
Collaborator

MatrixCrawler commented Apr 22, 2024

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.

@MatrixCrawler MatrixCrawler linked a pull request Apr 22, 2024 that will close this issue
@yermulnik
Copy link
Collaborator

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 😺

@shadycuz
Copy link
Author

I will try and re-test soon

@MatrixCrawler MatrixCrawler self-assigned this Apr 23, 2024
@MatrixCrawler
Copy link
Collaborator

Any news on that @shadycuz ?

@shadycuz shadycuz closed this as completed Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Refactor existing code for better performance and quality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants