-
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
fixes(#814) allow plugins to extend the 'source' command group #818
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.
@maximilien: 0 warnings.
In response to this:
Description
In rare cases (e.g.,
source
) an existing command group should be extensible via plugins. This PR addresses that. Source should be extensible since many of the eventing sources will be supported via plugins.Changes
- introduce a list of command group that can be extended (currently only source)
- check if plugin main group is in that list and execute, otherwise fail
- add e2e test for both plugin that is allowed and not allowed to extend existing group
Reference
Fixes #814
/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.
/ok-to-test |
628ef79
to
458ad7c
Compare
* introduce a list of command group that can be extended (currently only source) * check if plugin main group is in that list and execute, otherwise fail * add e2e test for both plugin that is allowed and not allowed to extend existing group
The following is the coverage report on the affected files.
|
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.
tested the PR and seeing unknown command 'source'
➜ client git:(7b488dfe) ./hack/build.sh -f
🚧 Compile
➜ client git:(7b488dfe) ./kn plugin list
/home/nshaikh/.config/kn/plugins/kn-source-test.sh
ERROR:
- kn-source-test.sh overwrites existing built-in command: kn source
kn-source-test.sh overwrites existing built-in command: kn source
➜ client git:(7b488dfe) ./kn source test
Error: unknown command 'source'
Run 'kn --help' for usage.
Hmm, OK, thx, let me double check. Not seeing this on my side. |
/hold |
OK @navidshaikh back on this. I think I see what's going on, I need to add more code to the ➜ client git:(issue814) ls -la ~/.config/kn/plugins
total 87240
drwxr-xr-x 5 maximilien staff 160 Apr 28 15:24 .
drwxr-xr-x 3 maximilien staff 96 Apr 6 19:03 ..
-rwxr-xr-x 1 maximilien staff 804 Mar 17 16:57 kn-curl
-rwxr-xr-x 1 maximilien staff 35 Apr 28 15:24 kn-source-create
-rwx------ 1 maximilien staff 44657756 Apr 23 18:23 kn-source-github
➜ client git:(issue814) cat ~/.config/kn/plugins/kn-source-create
#!/bin/bash
echo "Hello kn: $1 $2"
➜ client git:(issue814) ./kn source create max
Hello kn: max Let me try and add a fix for |
* added tests for the public function * change verifier to use IsAllowedExtensibleCommandGroup to allow plugins for extensible command groups
@navidshaikh see latest updates. Also did a series of local tests that worked well for me: ➜ client git:(issue814) ✗ ls -la ~/.config/kn/plugins
total 87256
drwxr-xr-x 7 maximilien staff 224 Apr 28 15:49 .
drwxr-xr-x 3 maximilien staff 96 Apr 6 19:03 ..
-rwxr-xr-x 1 maximilien staff 804 Mar 17 16:57 kn-curl
-rwxr-xr-x 1 maximilien staff 35 Apr 28 15:49 kn-service-create
-rwxr-xr-x 1 maximilien staff 35 Apr 28 15:49 kn-service-max
-rwxr-xr-x 1 maximilien staff 35 Apr 28 15:24 kn-source-create
-rwx------ 1 maximilien staff 44657756 Apr 23 18:23 kn-source_github
➜ client git:(issue814) ✗ ./kn plugin list
/Users/maximilien/.config/kn/plugins/kn-curl
/Users/maximilien/.config/kn/plugins/kn-service-create
/Users/maximilien/.config/kn/plugins/kn-service-max
/Users/maximilien/.config/kn/plugins/kn-source-create
/Users/maximilien/.config/kn/plugins/kn-source_github
ERRORs:
- kn-service-create overwrites existing built-in command: kn service create
- kn-service-max overwrites existing built-in command: kn service
kn-service-create overwrites existing built-in command: kn service create,kn-service-max overwrites existing built-in command: kn service
➜ client git:(issue814) ✗ ./kn service max
Error: unknown subcommand 'max' for 'kn service'. Available subcommands: create, delete, describe, export, list, update
Run 'kn --help' for usage.
➜ client git:(issue814) ✗ ./kn source create max
Hello kn: max
➜ client git:(issue814) rm ~/.config/kn/plugins/kn-service-*
➜ client git:(issue814) ls -la ~/.config/kn/plugins
total 87240
drwxr-xr-x 5 maximilien staff 160 Apr 28 15:59 .
drwxr-xr-x 3 maximilien staff 96 Apr 6 19:03 ..
-rwxr-xr-x 1 maximilien staff 804 Mar 17 16:57 kn-curl
-rwxr-xr-x 1 maximilien staff 35 Apr 28 15:24 kn-source-create
-rwx------ 1 maximilien staff 44657756 Apr 23 18:23 kn-source_github
➜ client git:(issue814) ./kn plugin list
/Users/maximilien/.config/kn/plugins/kn-curl
/Users/maximilien/.config/kn/plugins/kn-source-create
/Users/maximilien/.config/kn/plugins/kn-source_github
➜ client git:(issue814) ./kn source create max
Hello kn: max Hopefully we can merge this as @daisy-ycguo and I need this feature for our |
/test pull-knative-client-build-tests |
/retest |
/hold cancel |
/retest |
usable in windows builds
Hi, @navidshaikh, we should be good to go now. Please merge when greeen. cc @daisy-ycguo |
/retest |
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.
Should we consider to allow plugins to extend (all) command groups and report only when there is clash ?
err = ctx.execute("plugin", "list", "--lookup-plugins=true") | ||
assert.NilError(t, err) |
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.
should this also verify the plugin name from the returned list ?
// extended with plugins, e.g., a plugin named `kn-source-kafka` for Kafka | ||
// event sources is allowed. This is defined as a fixed [...]string since | ||
// cannot defined Golang []string constants | ||
var AllowedExtensibleCommandGroups = [...]string{"source"} |
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 the command group to extend should be configurable outside the kn, i.e config.
OR
IMO, it shouldn't mind extending command groups if the plugin commands dont clash with kn's own commands.
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.
Not sure about that since we would not want extensions of core commands
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.
as per today’s discussion, please merge this PR and I will open an issue with your suggestion with more details and open a 24 hours vote. Thanks @navidshaikh and @rhuss
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.
/lgtm
Lets merge this to unblock contrib source plugins. We'd like to allow extending the command groups via plugins as long as it doesnt clash with kn's own commands.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: maximilien, navidshaikh 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 |
Description
In rare cases (e.g.,
source
) an existing command group should be extensible via plugins. This PR addresses that. Source should be extensible since many of the eventing sources will be supported via plugins.Changes
Reference
Fixes #814
/lint