Skip to content
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(#827): allow plugins to extend all command groups #834

Merged
merged 3 commits into from
Jun 1, 2020

Conversation

maximilien
Copy link
Contributor

Description

Allow kn plugins to extend existing command groups. So a plugin named: kn-service-blah is now allowed. It extends the service command group with command blah. These extensions are for any existing command groups. This is per issue #827

Changes

  • allow plugins to extends all command groups, e.g., kn-service-blah is OK
  • prevent plugins that shadow commands of existing groups, e.g., kn-service-create is NOT OK
  • list plugins that extend existing groups
  • warn plugins that shadow command of existing groups
  • add UTs for above

Reference

Fixes #827

/lint

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label May 12, 2020
@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 12, 2020
Copy link
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maximilien: 1 warning.

In response to this:

Description

Allow kn plugins to extend existing command groups. So a plugin named: kn-service-blah is now allowed. It extends the service command group with command blah. These extensions are for any existing command groups. This is per issue #827

Changes

  • allow plugins to extends all command groups, e.g., kn-service-blah is OK
  • prevent plugins that shadow commands of existing groups, e.g., kn-service-create is NOT OK
  • list plugins that extend existing groups
  • warn plugins that shadow command of existing groups
  • add UTs for above

Reference

Fixes #827

/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.

pkg/kn/commands/plugin/plugin.go Outdated Show resolved Hide resolved
@knative-prow-robot knative-prow-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 12, 2020
@maximilien
Copy link
Contributor Author

/ok-to-test

@knative-prow-robot knative-prow-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label May 12, 2020
@maximilien maximilien changed the title fixes(#827): allow plugins to extends all command groups fixes(#827): allow plugins to extend all command groups May 12, 2020
@maximilien
Copy link
Contributor Author

To reviewers. Some local tests I have done that might be useful to verify this yourself.

➜  client git:(issue827) ./kn plugin list
/Users/maximilien/.config/kn/plugins/kn-curl
/Users/maximilien/.config/kn/plugins/kn-service-blah
/Users/maximilien/.config/kn/plugins/kn-service-create
/Users/maximilien/.config/kn/plugins/kn-source-create
/Users/maximilien/.config/kn/plugins/kn-source_github
ERROR:
  - kn-service-create overwrites existing built-in command: kn service create
kn-service-create overwrites existing built-in command: kn service create
➜  client git:(issue827) cat /Users/maximilien/.config/kn/plugins/kn-service-blah
#!/bin/bash
echo "Hello kn: $1 $2"
➜  client git:(issue827) ./kn service blah max
Hello kn: max
➜  client git:(issue827) ./kn service create
required flag(s) "image" not set
➜  client git:(issue827) ./kn service list
NAME          URL                                                                                                            LATEST                AGE   CONDITIONS   READY   REASON
hello-world   http://hello-world-default.kn-plugins-a4511d9cf0901749cf183d1384ce2bca-0000.sjc04.containers.appdomain.cloud   hello-world-kzyhx-1   55d   3 OK / 3     True

@maximilien
Copy link
Contributor Author

Ok looks like I need to add more tests to root.go so that the coverage gets above 50%.

Will work on that tomorrow.

/hold

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 12, 2020
@knative-prow-robot knative-prow-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 12, 2020
@maximilien
Copy link
Contributor Author

/hold cancel

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 12, 2020
…is OK

* prevent plugins that shadow commands of exsiting groups, e.g., kn-service-create is NOT OK
* list plugins that extend existing groups
* warn plugins that shadow command of existing groups
* add UTs for above
@maximilien
Copy link
Contributor Author

Looks like I am still not over 50% coverage for root.go :(

coryrc pushed a commit to coryrc/client that referenced this pull request May 14, 2020
* Wait on istio before installing knative serving

* retry knative serving install if it fails

* retry the serving install once after 60 second if it fails the first time

* Added logs for the retry serving install and wait on istio components

* Update comment for waiting on istio installation if necessary

Co-Authored-By: Adriano Cunha <[email protected]>
Copy link
Contributor

@rhuss rhuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks good ! I have adde some minor comments/requests inline .

pkg/kn/commands/plugin/plugin.go Show resolved Hide resolved
pkg/kn/commands/plugin/plugin_test.go Outdated Show resolved Hide resolved
pkg/kn/core/root.go Outdated Show resolved Hide resolved
pkg/kn/core/root.go Show resolved Hide resolved
pkg/kn/core/root_test.go Show resolved Hide resolved
@maximilien
Copy link
Contributor Author

/retest

go: github.com/google/licenseclassifier upgrade => v0.0.0-20200402202327-879cb1424de0
go: downloading github.com/sergi/go-diff v1.0.0
go: github.com/sergi/go-diff upgrade => v1.1.0
go: downloading github.com/sergi/go-diff v1.1.0
2020/05/22 21:54:37 Error creating license classifier: cannot register licenses: EOF
Step failed: default_build_test_runner
============================
==== BUILD TESTS FAILED ====
============================
==== Fri May 22 14:54:37 PDT 2020
============================
Step failed: run_build_tests
+ EXIT_VALUE=1
+ set +o xtrace

@maximilien
Copy link
Contributor Author

Getting a weird error....

go: github.com/google/licenseclassifier upgrade => v0.0.0-20200402202327-879cb1424de0
go: downloading github.com/sergi/go-diff v1.0.0
go: github.com/sergi/go-diff upgrade => v1.1.0
go: downloading github.com/sergi/go-diff v1.1.0
2020/05/22 21:54:37 Error creating license classifier: cannot register licenses: EOF
Step failed: default_build_test_runner
============================
==== BUILD TESTS FAILED ====
============================
==== Fri May 22 14:54:37 PDT 2020
============================
Step failed: run_build_tests
+ EXIT_VALUE=1
+ set +o xtrace

@maximilien
Copy link
Contributor Author

/retest

@maximilien
Copy link
Contributor Author

Same consistent CI issue:

2020/05/22 21:54:37 Error creating license classifier: cannot register licenses: EOF
Step failed: default_build_test_runner

I'll have to take a look at this next Tuesday --- long weekend here in US due to Memorial Day.

@rhuss
Copy link
Contributor

rhuss commented May 25, 2020

Looks like an incompatible change in the test-infra scripts. @coryrc do you have an idea what has changed ? I think we have the same kind of error over there for client-contrib tests, too.

@rhuss
Copy link
Contributor

rhuss commented May 25, 2020

/retest

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 26, 2020
@rhuss
Copy link
Contributor

rhuss commented May 27, 2020

@maximilien the IT tests should be running again, but there's a conflict now which needs to be resolved.

CHANGELOG.adoc Outdated Show resolved Hide resolved
* addressed comments on PR
* fix bug when dealing with sub sub-commands for known commands
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 28, 2020
@maximilien
Copy link
Contributor Author

OK thanks @rhuss and @navidshaikh. Just merged. Let's see what other tests I need to add or not.

@maximilien
Copy link
Contributor Author

maximilien commented May 28, 2020

@rhuss and @navidshaikh this passes now and is ready. However, I want to make some small refactoring to simplify the code in root.go a bit and add more comments. Mostly to make it more readable. Will push an update in next hour and we should be good to go.

* change root.go to match merge conflict
* cleaned up NewDefaultKnCommandWithArgs call and added more comments
@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-knative-client-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/kn/core/root.go 51.7% 51.6% -0.1

@rhuss
Copy link
Contributor

rhuss commented Jun 1, 2020

Cool, let's get that merged now.

As I'm starting to work now to include grouping for help messages (#579) and also to weave in plugin help message is needed. This will probably lead to some refactoring also in this part, so please don't touch those in the next week for now.

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 1, 2020
@knative-prow-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot merged commit e1ad66a into knative:master Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Supporting extending all command groups?
6 participants