minamijoyo / tfupdate

Update version constraints in your Terraform configurations
MIT License
556 stars 23 forks source link

Don't show pre-releases in tfupdate release list #31

Closed robinbowes closed 3 years ago

robinbowes commented 3 years ago

At time of writing, tfupdate release list -n 5 hashicorp/terraform shows the following output:

0.13.4
0.14.0-alpha20201007
0.14.0-beta1
0.13.5
0.14.0-beta2

I think the tfupdate release comand should not show pre-release versions by default.

Would it be possible to add a --pre-release switch?

robinbowes commented 3 years ago

I think you should be able to filter the results from the github API on the prerelease field. This is the equivalent using bash/curl/jq:

jq -r '.[] | select(.prerelease == false) | .tag_name' < <(
  curl --silent https://api.github.com/repos/hashicorp/terraform/releases
)
minamijoyo commented 3 years ago

@robinbowes Thank you for your proposal!

The release interface is not only used with github but also shared with gitlab, tfregistryModule and tfregistryProvider. The latter does not include prerelease information in the response. Of course, It is possible to detect it from the version number based on semantic versioning.

By the way, I use the release list command only for debugging, and use the release latest command for automation, which doesn't include prerelease. So I'm not sure why you want to hide prerelease versions in the release list command. Could you share your use-case?

robinbowes commented 3 years ago

I wanted to see the latest releases so I chose to use tfupdate release list and was surprised that pre-releases were included. If the command was tfupdate version list, that would make more sense, but to include things that arenot releases in a release list command seems wrong.

I guess it doesn't cause any major issues, other than being a bit noisy.

minamijoyo commented 3 years ago

but to include things that arenot releases in a release list command seems wrong.

For the GitHub REST API model, prerelease is a kind of release because it is returned by the List Releases API. https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#releases

I wanted to see the latest releases so I chose to use tfupdate release list and was surprised that pre-releases were included.

If you want to see the latest release, you can use the release latest command, which returns 0.13.5 at the time of writing even if there are 0.14 alpha or beta releases.

$ tfupdate release list -n 5 hashicorp/terraform
0.13.4
0.14.0-alpha20201007
0.14.0-beta1
0.13.5
0.14.0-beta2

$ tfupdate release latest hashicorp/terraform
0.13.5

Why don't you simply use the release latest command to get the latest release instead of the release list? Is there any reason? For example, you want to show 0.12 series etc...

minamijoyo commented 3 years ago

Fixed in v0.5.0