-
Notifications
You must be signed in to change notification settings - Fork 369
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
Randomly check for krew updates #494
Randomly check for krew updates #494
Conversation
Codecov Report
@@ Coverage Diff @@
## master #494 +/- ##
=========================================
+ Coverage 57% 58.21% +1.2%
=========================================
Files 21 22 +1
Lines 956 974 +18
=========================================
+ Hits 545 567 +22
+ Misses 357 351 -6
- Partials 54 56 +2
Continue to review full report at Codecov.
|
cmd/krew/cmd/root.go
Outdated
const ( | ||
upgradeNotification = `A newer version of krew is available (%s -> %s). | ||
Run "kubectl krew upgrade" to get the newest 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.
maybe remove newline and use println?
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.
Println is not possible due to the format string. I changed to a normal string instead.
internal/updatecheck/update.go
Outdated
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package updatecheck |
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.
I don't know why you want to make a new pkg out of this tbh :)
it's like 3 short methods.
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.
Yeah.. true. I'll move to cmd/internal
No major issues just some nits+refactoring feedback. |
Ok, I hope I got everything. |
As this is a convenience function, silently ignore errors if they occur. Show notifications right before the command completes Add env var KREW_NO_UPGRADE_CHECK as switch to disable the upgrade check.
a95789a
to
956e101
Compare
cmd/krew/cmd/root.go
Outdated
return nil | ||
} | ||
|
||
func showUpgradeNotification(*cobra.Command, []string) { | ||
if latestTag == "" || latestTag == version.GitTag() { |
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.
I think I've mentioned this before: Let's parse both of these into semver, and actually do LessThan
check.
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.
Yes, I also explained why I think that mere string comparison is better:
We only allow the version numbers of krew releases to advance, so that it is equivalent to check for string equality vs. semver less-than comparison.
But if you feel so strongly about it, let's change it.
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.
I feel like we're gonna see upgrade notifications etc in CI tests.
If it's not a big deal, let's just do that. We already have the code, and we'd simply skip if it fails to parse as semver.
Signed-off-by: Ahmet Alp Balkan <[email protected]>
Added a commit PTAL. |
Oh yes, make sense. Thanks! |
(Closed by mistake) 🗡 I've encountered this: On local builds, it prints
I guess this is expected, because, technically, pre-release tags are LessThan their tags. 🤦♂ What do we do? |
I guess this problem only impact developers. I hope the devs can understand what's going on. If you have any solutions, please send follow-up PR. /lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ahmetb, corneliusweig The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Let's see if annoying this is to us. I'd like to avoid complexity if it only solves a minor inconvenience for a few krew developers. Btw, thanks for pushing this PR in the right direction until it became reasonably small! |
Fixes #480
Related issue: #490
This is an alternate implementation of #490. The goal here is to simplify the feature. Instead of saving the timestamp of the last update check, the checks are now done at random with a probability of 40% per run. In addition, no checks are done for development builds.
As this is a convenience function, silently ignore errors if they occur.
Show notifications right before the command completes
Add env var KREW_NO_UPGRADE_CHECK as switch to disable the upgrade check.