-
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
feature(kn plugins): Implements Kn plugins re-using some code from kubectl plugins. #249
Conversation
OK so
Fair and good catch. I will add these tomorrow and update this PR. However, feel free to start your review and/or testing this. Thx. |
This version contains the following: 1. wraps the main root Kn command to support plugin 2. plugins are any executable in kn's config new pluginDir variable which defaults to $PATH 3. plugins must have name kn-* 4. 'kn plugin list' sub-command to list found kn plugins 5. skips any kn plugins found with name that match core commands, e.g., kn-service would be ignored 6. can execute any valid kn plugins found, e.g., `kn valid` where the plugin file `kn-valid` is in path specified in 2. 7. unit tests (using gotest.tools) And is missing: 1. integration tests 2. plugin install command 3. plugin repository command 4. plugin / Knative server version negotiation 5. anything else we agree on in plugin req doc I plan to create issues for the things missing so we don't end up with an even bigger PR. It's already big as is but is a good MVP as per plugins requirement doc.
OK added tests (lots) for I'll work on adding for |
Maybe now it's a good time to move help_testing.go to helper_test.go ? ;-) |
OK, we are ping ponging this file, but ➜ client git:(kn-plugins4) ✗ ./hack/build.sh
🧽 Format
⚖️ License
📖 Docs
🚧 Compile
🧪 Test
🔥 Failure
=== RUN TestDummy
--- PASS: TestDummy (0.00s)
PASS
ok github.com/knative/client/pkg (cached)
# github.com/knative/client/pkg/kn/commands/plugin [github.com/knative/client/pkg/kn/commands/plugin.test]
pkg/kn/commands/plugin/path_verifier_test.go:35:18: undefined: commands.CreateTestKnCommand
pkg/kn/commands/plugin/plugin_list_test.go:40:19: undefined: commands.CreateTestKnCommand
[...] Unless I am missing something, I think the only thing I can do is to have it as |
Ok, I see. I really talked with some folks who know testing better than me, and they assured me its possible to have _test.go files without any tests which are used only during tests. That's why is so dogged ;) Let's get the fixed because I really think that these helpers should be reachable only in test scope. |
Let me push the |
d44b95b
to
0c6ebac
Compare
OK @rhuss and others, this version has all the test but the coverage fails since I have a common I think we need to ask the // +build !linux
... Perhaps @adrcunha has some magic up his sleeves already... I know he's been super helpful in the past. Hoping. |
Its current code coverage is at 47%. 3pp more and the code coverage job will pass. If you click the file name in the coverage report above you'll see the methods that weren't tested. I think I mentioned it in some other PR, but if the requirement of having at least 50% code coverage in PRs is currently too hard, an admin can mark the job optional so it won't block submissions. |
OK @rhuss and @sixolet. Pushed latest version. It's close but not quite ready as I can see three remaining issues:
That said, one approach if the current code looks good to you is to merge so I can address these issues separately. Otherwise, I'll keep churning tomorrow and get this PR with fixes for above. Let me know if you also see any additional issues. Thanks. |
I will have a look tomorrow morning our time (but from my understanding I'm really not sure that (a) we need both options and (b) whether it should be not only configuration variables. |
OK @rhuss and @sixolet this is ready to merge. Assuming I pass CI. Please note:
Ping me on Slack if you need my urgent attention on something. Would be good to have this in soon. Thx. |
I don't think it was about a configurable prefix what @sixolet meant (but to avoid a prefix in ~/.kn/plugins as its redundant). I added my opinion on this in #288 (comment) and why I think this is not a good idea. |
@maximilien I'm going to make my review later today. sorry for the delay, just tons on my plate right now :( |
Fully understood. You are great at reviews so not worried. I’ll submit the kn plugins IT as separate PR that depends on this one. Thanks! |
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.
Thanks for revisiting this PR ! I'm somewhat fine with this PR (although most of my comments were not addressed) except two things which I consider as blocking issues:
- The lookup order should be always pluginDir before PATH and PATH lookup should just be skipped when
lookupInPath
is false. See feature(kn plugins): Implements Kn plugins re-using some code from kubectl plugins. #249 (comment) - The extracting of plugin names with options interspersed is broken (as already mentioned in the first review). See feature(kn plugins): Implements Kn plugins re-using some code from kubectl plugins. #249 (comment)
When those two are fixed, IMO we can merge that and I would address then the following concerns:
- Using
os.Separator
- No global commandline options, just config vars
- Executable check
- Only one prefix
- Dangerous assumption about the first parameter in Verify()
I think it's better now to elaborate on my points in code than in comments.
The following is the coverage report on pkg/.
|
The following is the coverage report on pkg/.
|
OK @rhuss see latest update. Passes CI and my local ITs---I will submit different issue/PR for that soon today or Monday worst case. Ping me if any other issues. I'll monitor slack. Thx. |
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.
Thanks a lot for the quick fix ! lgtm and I will follow up with my suggestions which we then can discuss in the next month or so ;-P
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: maximilien, 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 |
@sixolet I think you need to also add your lgtm. Or let me know if something urgent is missing. Planning to open issues on items that require more discussions and agreement, e.g., prefix. |
I think we are good for now, but with some homework left. 'happy to take that over. Thanks a ton to @maximilien for doing the hard work ! |
…ve#249) This version contains the following: 1. wraps the main root Kn command to support plugin 2. plugins are any executable in kn's config new pluginDir variable which defaults to $PATH 3. plugins must have name kn-* 4. 'kn plugin list' sub-command to list found kn plugins 5. skips any kn plugins found with name that match core commands, e.g., kn-service would be ignored 6. can execute any valid kn plugins found, e.g., `kn valid` where the plugin file `kn-valid` is in path specified in 2. 7. unit tests (using gotest.tools) And is missing: 1. integration tests 2. plugin install command 3. plugin repository command 4. plugin / Knative server version negotiation 5. anything else we agree on in plugin req doc I plan to create issues for the things missing so we don't end up with an even bigger PR. It's already big as is but is a good MVP as per plugins requirement doc.
This version contains the following:
variable which defaults to $PATH
commands, e.g., kn-service would be ignored
kn valid
where the plugin filekn-valid
is in pathspecified in 2.
And is missing:
I plan to create issues for the things missing so we don't
end up with an even bigger PR. It's already big as is but is a
good MVP as per plugins requirement doc.
Fixes #92