-
Notifications
You must be signed in to change notification settings - Fork 263
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
Look up plugins on $PATH by default #1412
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.
@psschwei: 0 warnings.
In response to this:
Description
Look for knative plugins on the user's $PATH by default
Changes
- Removed the
lookupInPath
option and enabled the logic it gated by default- Removed all references to disabling the path lookup in the code and tests
This results in the following behavior (copying from Roland's comment):
- Lookup plugins from both, the path and
~/.config/kn/plugins
.- Same named plugin in
~/.config/kn/plugins
take precedence over plugins found on the PATH.This would also allow for system-wide plugins as installed by brew in
/usr/local/bin
, but allow individual users to override plugins in their~/.config/kn/plugins
directory. Also, for people that currently collect their plugins in~/.config/kn/plugins
nothing would change. It's just as if you would add this directory to the front of your $PATH.Reference
Fixes #1399
(adoc to be added after PR creation)
/lint
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
Codecov Report
@@ Coverage Diff @@
## main #1412 +/- ##
=======================================
Coverage 78.51% 78.51%
=======================================
Files 160 160
Lines 8285 8285
=======================================
Hits 6505 6505
Misses 1097 1097
Partials 683 683
Continue to review full report at Codecov.
|
The following is the coverage report on the affected files.
|
6d790e3
to
74f771e
Compare
/hold @rhuss @maximilien any preference as to whether we do this all in one shot (remove the config variable now) or if it's done piecemeal (change default value in this PR, remove variable in follow up PR)? (my thought was the latter to be sure the change would land in the next release) |
🤔 Don't think changing the default value of |
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.
You may need to change some tests @psschwei
/ok-to-test |
Interestingly, when I was testing locally, the
Let me look at the test itself... (I wasn't able to figure out what exactly the |
Ok, looks like it's not a test issue, but rather something with how I ran the following in the terminal:
... and got the same error I saw in the test. It appears it's translating
So I'm somewhat confident that the test failure I'm seeing isn't related to my PR. Before I go too far down the rabbit hole looking at |
Indeed we fail to look up in path when there's slash in arguments. I'm looking into why client/pkg/kn/plugin/manager.go Lines 468 to 477 in c18a55f
A simple skip of such argument seems to be enough, before it's added to suspected name. index f9b9e284..ca7a8c89 100644
--- a/pkg/kn/plugin/manager.go
+++ b/pkg/kn/plugin/manager.go
@@ -403,6 +403,9 @@ func findMostSpecificPluginInPath(dir string, parts []string, lookupInPath bool)
for _, p := range parts[0:i] {
// Subcommands with "-" are translated to "_"
// (e.g. a command "kn log-all" is translated to a plugin "kn-log_all")
+ if strings.Contains(p, "/") || strings.Contains(p, "\\") {
+ continue
+ }
nameParts = append(nameParts, convertDashToUnderscore(p))
commandParts = append(commandParts, p)
} Update:
So that's an explanation. https://cs.opensource.google/go/go/+/refs/tags/go1.16.6:src/os/exec/lp_unix.go;l=33 |
@psschwei that's a nice bug catch! :) |
Thanks @dsimansk ! Can confirm that your fix does solve the test problem:
(run with I opened #1415 as a fix |
74f771e
to
53e74db
Compare
/hold cancel |
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.
Looks good, but maybe let's already add a deprecation for this configuration variable ? (so that we can remove it earlier in 0.29 ?)
Let's get this merged and I'll send a followup PR.
/approve
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: psschwei, rhuss 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 |
Sorry @rhuss , I totally spaced on the docs |
Description
Look for knative plugins on the user's $PATH by default
Changes
lookupPluginsInPath
totrue
This results in the following behavior (copying from Roland's comment):
This would also allow for system-wide plugins as installed by brew in
/usr/local/bin
, but allow individual users to override plugins in their~/.config/kn/plugins
directory. Also, for people that currently collect their plugins in~/.config/kn/plugins
nothing would change. It's just as if you would add this directory to the front of your $PATH.Reference
Fixes #1399
/lint