-
Notifications
You must be signed in to change notification settings - Fork 359
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 remote version check #1735
base: master
Are you sure you want to change the base?
Add remote version check #1735
Conversation
6abeee1
to
6fc0d18
Compare
6fc0d18
to
cc98764
Compare
@wata727 please take a look |
|
||
func getLatestVersion() (*github.RepositoryRelease, error) { | ||
ghClient := github.NewClient(nil) | ||
releases, _, err := ghClient.Repositories.ListReleases(context.Background(), |
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.
Keep all args on one line or if that line gets too long each arg should be its own line. Mixing both style is awkward.
} | ||
|
||
func getLatestVersion() (*github.RepositoryRelease, error) { | ||
ghClient := github.NewClient(nil) |
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.
This needs to be authenticated if a token is provided, for rate limiting purposes. See plugin.newGitHubClient
.
} | ||
|
||
// GitHub sorts releases results. Select first non-prerelease version and return it. | ||
for i := range releases { |
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.
for _, release := range
|
||
// Checks GitHub releases and prints new version, if current version is outdated. | ||
// requires GitHub releases to follow semver. | ||
func (cli *CLI) printLatestReleaseVersion() { |
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.
There should be a way to disable this, e.g., for users who want to run TFLint offline. See https://developer.hashicorp.com/terraform/cli/commands#upgrade-and-security-bulletin-checks.
} | ||
compare := tflint.Version.Compare(latestVersion) | ||
if compare < 0 { | ||
fmt.Fprintf(cli.outStream, "New version available: %s\n", *latest.HTMLURL) |
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 prints, for example:
Your version of Terraform is out of date! The latest version
is 1.4.4. You can update by downloading from https://www.terraform.io/downloads.html
It would be nice to do something similar, namely:
- The new version
- The URL
You already have the latter here.
|
||
func getLatestVersion() (*github.RepositoryRelease, error) { | ||
ghClient := github.NewClient(nil) | ||
releases, _, err := ghClient.Repositories.ListReleases(context.Background(), |
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.
This should use /releases/latest
and not list releases:
https://docs.github.com/en/rest/releases/releases?apiVersion=2022-11-28#get-the-latest-release
That will handle excluding prereleases and drafts. Alternatively, if we had to use list, we should be fetching smaller pages than the 30 returned by default.
@uthark Any updates? Still interested in finishing this? |
I’ll take a look on the weekend and get back to you.
Best regards,
Oleg.
…On Sun, Sep 3, 2023 at 08:30 Kazuma Watanabe ***@***.***> wrote:
@uthark <https://github.com/uthark> Any updates? Still interested in
finishing this?
—
Reply to this email directly, view it on GitHub
<#1735 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABK75STQ2G5XG55WJ6O47DXYSPATANCNFSM6AAAAAAWTRX6ZQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Fixes #883