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

tfswitch -v should not apply anything - it should only print the tfswitch version #443

Closed
warrensbox opened this issue Jun 1, 2024 · 4 comments · Fixed by #446
Closed
Assignees
Labels
bug Something isn't working

Comments

@warrensbox
Copy link
Owner

Is your feature request related to a problem? Please describe.
Currently the tfswitch -v reads config files and applies them when you pass -v. Previously, it only printed the tfswitch version

Describe the solution you'd like
tfswitch -v should not apply anything - it should only print the tfswitch version

Current:

warrenv@mass ~/WarrensBox/go/src/github.com/warrensbox/tfswitch/test-data/integration-tests/test_versiontf --> tfswitch -v
13:39:12.681 INFO Reading version from Terraform module at "."
13:39:12.754 INFO Reading required version from constraint: "1.6.3"
13:39:12.755 INFO Matched version: "1.6.3"
Version: v1.1.1

Needs to look like:

Version: v1.1.1
@warrensbox warrensbox added the bug Something isn't working label Jun 1, 2024
@MatthewJohn
Copy link
Collaborator

I guess there's a couple of options here:

  • Change all of the logging in parameter parsing to use debug (if it's working as normal - do people care where it detected the version from)
  • Hack a particular log level for this particular command (though, this is even harder because we don't match the command until after we've done all of the parameter parsing)
  • Switch logging to STDERR (think this has been discussed before and is standard for tools where users expect to consume output from stdout)

@yermulnik
Copy link
Collaborator

yermulnik commented Jun 4, 2024

@MatthewJohn For this particular issue, I think it's not about logging, but about -v, --version Displays the version of tfswitch not needing to go through all the logic and read TF version, but bail out quickly and print tfswitch version.

@yermulnik
Copy link
Collaborator

yermulnik commented Jun 4, 2024

Like not proceed all the way down to the end of function from https://github.com/warrensbox/terraform-switcher/blob/master/lib/param_parsing/parameters.go#L54, but instead print version and exit return immediately to proceed with https://github.com/warrensbox/terraform-switcher/blob/master/main.go#L35-L41

@yermulnik
Copy link
Collaborator

Hmm, it's a bit wider issue where we'd want more options to omit TF version exploration. Ex: #420 (reply in thread)

From what I see at https://github.com/warrensbox/terraform-switcher/blob/master/lib/param_parsing/parameters.go#L35-L50, we should skip finding TF version for these options:

  • params.HelpFlag
  • params.LatestFlag
  • params.LatestPre
  • params.LatestStable
  • params.ListAllFlag
  • params.ShowLatestFlag
  • params.ShowLatestPre
  • params.ShowLatestStable
  • params.VersionFlag

MatrixCrawler added a commit that referenced this issue Jun 4, 2024
…-does-not-work-under-windows

Fix for #443 - Error unzipping on windows systems
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants