Replies: 1 comment 4 replies
-
Would the below work for your use case? tfswitch -d $(tfswitch -U -g ERROR | awk 'END {print $NF}' | sed 's/\x1b\[[0-9;]*[mGKHF]//g')
|
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am in a situation where I am automatically running tfswitch for users based on different scenarios.
They can either define a constraint in their terraform block and have tfswitch download the matching version or do nothing and have tfswitch download the latest version available. The issue is, due to the behaviour of running tfswitch --latest, it acknowledges the version constraint in the files but then ignores it to download the latest existing version, as shown below.
❯ tfswitch --latest 11:42:33.966 INFO Reading version from Terraform module at "." 11:42:34.063 INFO Reading required version from constraint: "~> 1.5.0" 11:42:34.064 INFO Matched version: "1.5.7" 11:42:34.158 INFO Switched terraform to version "1.8.5"
I don't want to read in their terraform configuration BEFORE calling tfswitch because tfswitch already has that functionality built in, however I need to know that information before I run the tfswitch command, as it decides whether I run
tfswitch
ortfswitch --latest
It would be good if there was a flag to not have the interactive selection when not passing a version and not having a version constraint in your tf code, i.e. a
--latest
flag that does not ignore the constraints in the code, but instead defaults to the latest if no constraint is found.--latest-within-constraint
if that makes sense.I may be missing something obvious that meets my use case 😅 but from reading through docs and playing around at the CLI, I haven't seen anything yet
Beta Was this translation helpful? Give feedback.
All reactions