-
Notifications
You must be signed in to change notification settings - Fork 137
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 show latest command that prints latest version that conform to contraints #536
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Should we deem feat: allow to show required by module version explicitly #301 obsolete and close in favour of this PR? (I'm closing that PR for now)
- Do we need any tests for this new arg?
- On a side note, we probably may need to look into restraining simultaneous use of cmdline args that are not compatible with each other (I mean this is a thought aloud)
- I added commit suggestions to try and align this new arg with what it actually does (e.g. when version is provided via command line, this new arg does not show latest required, but outputs version requested on command line. same for
version
parameter in TOML. so on by means of all of theif
s fromlib/param_parsing/parameters.go
). WDYT? - Let me know if you'd like me to postpone new version release for
--arch
arg to get this PR added to the same release (or to cut next release for it later)
MirrorURL string | ||
ShowLatestFlag bool | ||
ShowLatestPre string | ||
ShowLatestRequiredFlag bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Flag
suffix looks pointless to me. Not sure what its value is and not sure why it was added to a few others in past. I guess the only exception are Version
and VersionFlag
(where both could have a more clear names though).
Would you mind removing this suffix so this new flag is in consistency with similar ones nearby?
Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ShowLatestRequiredFlag bool | |
ShowRequired bool |
@@ -66,6 +67,7 @@ func populateParams(params Params) Params { | |||
getopt.StringVarLong(¶ms.LogLevel, "log-level", 'g', "Set loglevel for tfswitch. One of (ERROR, INFO, NOTICE, DEBUG, TRACE)") | |||
getopt.StringVarLong(¶ms.MirrorURL, "mirror", 'm', "install from a remote API other than the default. Default (based on product):\n"+strings.Join(defaultMirrors, "\n")) | |||
getopt.BoolVarLong(¶ms.ShowLatestFlag, "show-latest", 'U', "Show latest stable version") | |||
getopt.BoolVarLong(¶ms.ShowLatestRequiredFlag, "show-latest-required", 'R', "Show latest stable version, which complies to constraints set by Terraform/Terragrunt") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Terraform/Terragrunt and OpenTofu and by other allowed means like TOML file =)
getopt.BoolVarLong(¶ms.ShowLatestRequiredFlag, "show-latest-required", 'R', "Show latest stable version, which complies to constraints set by Terraform/Terragrunt") | |
getopt.BoolVarLong(¶ms.ShowRequired, "show-required", 'R', "Show version, which complies to version requested by configuration") |
@@ -177,6 +179,7 @@ func initParams(params Params) Params { | |||
params.MirrorURL = "" | |||
params.ShowLatestFlag = false | |||
params.ShowLatestPre = lib.DefaultLatest | |||
params.ShowLatestRequiredFlag = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
params.ShowLatestRequiredFlag = false | |
params.ShowRequired = false |
case parameters.ShowLatestRequiredFlag: | ||
/* show latest stable version within constraints */ | ||
lib.ShowLatestRequiredVersion(parameters.MirrorURL, parameters.Version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
case parameters.ShowLatestRequiredFlag: | |
/* show latest stable version within constraints */ | |
lib.ShowLatestRequiredVersion(parameters.MirrorURL, parameters.Version) | |
case parameters.ShowRequired: | |
/* show version requested by configuration */ | |
lib.ShowRequiredVersion(parameters.MirrorURL, parameters.Version) |
// ShowLatestRequiredVersion show latest version using constraints from TF | ||
func ShowLatestRequiredVersion(mirrorURL string, version string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// ShowLatestRequiredVersion show latest version using constraints from TF | |
func ShowLatestRequiredVersion(mirrorURL string, version string) { | |
// ShowRequiredVersion show latest version using constraints from TF | |
func ShowRequiredVersion(mirrorURL string, version string) { |
fmt.Printf("%s\n", version) | ||
return | ||
} | ||
logger.Fatal("The provided terraform version does not exist.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger.Fatal("The provided terraform version does not exist.") | |
logger.Fatalf("The requested version (%q) does not exist.", version) |
openAI
Do we need any tests for this new arg?
On a side note, we probably may need to look into restraining simultaneous use of cmdline args that are not compatible with each other
Let me know if you'd like me to postpone new version release for
@yermulnik feel free to do the deployments for the release |
Given the argument just prints to stdout and we don't have any mocking, I wonder if updating the function to return the string that is displayed to the user back to
The other argparsers I've seen have got this kind of functionality, but can't see viper does - assume it's something you had to do manually in the past?
👍
Yes, I agree none of it makes much sense given it's high dependency on the argument parsing - it's somewhat of a shame that this is all done magically behind before the |
I like the |
@warrensbox @MatthewJohn |
@MatthewJohn Will you be giving this PR some love? =) |
Hey sorry,
Had a little birth in the family - will take a look in tje next 24h when I’m next awake :)
…Sent from my iPhone
On 5 Feb 2025, at 12:50, George L. Yermulnik ***@***.***> wrote:
@MatthewJohn Will you be giving this PR some love? =)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
|
Ah, congrats 🥳 Take your time and take some sleep =))) |
Issue #301