Fix issue #205 to add route describe feature and test#251
Fix issue #205 to add route describe feature and test#251knative-prow-robot merged 1 commit intoknative:masterfrom zhangtbj:master
Conversation
|
Hi @zhangtbj. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
Hi @maximilien , @rhuss and @navidshaikh , Sorry I closed the previous PR #228 by mistake, this is the new one which is rebased from master and change to use new knClient. I think for the discussion for #206 and #235, it should be related to command Printer, should not change in each sub describe command. For example: So I think these should be the same for all subcommands, only change the implementation in Printer code. I am not sure if we could accept this PR first then change or refine the Thanks all!:) |
rhuss
left a comment
There was a problem hiding this comment.
Thanks for the PR and for adapting it to the lates refactorings.
As mentioned in #235 , the kn route describe is primarly (if not exclusively) for human readable output. If I understand the PR correctly, it returns the route as yaml (machine readable) presentation.
I'm not sure why the renaming of the files was needed wrt/ this PR. Could you please revert ?
As an intermediate step, I'm happy to include but we should go to a more human readable output as it is under the way for kn service describe.
|
/ok-to-test |
|
Thanks for the review @rhuss About Do you mean the change like this in PR?: I took a look the other command file styles, they are all format like this I think it makes people confusing (what list?) and not sync with other commands. If this is not a good place to fix it in this PR, I can revert it in here and just for |
Yes. Tbh, we already have a PR pending which does it the other way round for the other files #245 . So please revert that change and we can discuss that in another context. |
|
Sure thing @rhuss . I have reverted the renaming change. Pls review again. Thanks! |
Agree. Default output should be for us humans :) |
| }) | ||
|
|
||
| t.Run("describe a valid route with special output", func(t *testing.T) { | ||
| t.Run("describe a valid route with YAML output", func(t *testing.T) { |
There was a problem hiding this comment.
to simplify and make the test run output easier, I'd avoid duplicating the descriptions when nesting these t.Run("...") so for instance, I'd name these as follows:
[...]
t.Run("describe a valid route with special output", func(t *testing.T) {
t.Run("YAML", func(t *testing.T) {
[...]
})
})
[...]See output of test runs to see what I mean. Try to do the same in subsequent nested t.Run(...)
There was a problem hiding this comment.
Thanks Max, I have fixed in my PR
| validateGroupVersionKind(t, route) | ||
| }) | ||
|
|
||
| t.Run("get unknown route name returns error", func(t *testing.T) { |
There was a problem hiding this comment.
Is there a need for a check for invalid route names?
There was a problem hiding this comment.
Hi Max, I think it is better for us to cover the invalid failure case and I found we also have this invalid cases for service and revision.
There was a problem hiding this comment.
No I was thinking about user’s passing a route name like @#$Q!$# or anything with invalid HTTP char will be invalid. The API might have a specification as to what route names are valid.
The key for me is not so much that we guard against the valid or invalid name but that we tell user a message that’s easy to understand.
There was a problem hiding this comment.
Hi @maximilien , got it. I have tried, no matter it is a non-exist or invalid name, kn client can report routes.serving.knative.dev "xxx" not found correctly without any http error. such as:
jordan at jordandembp.cn.ibm.com in ~/Work/workspace/go/src/github.com/knative/client [master|✔]
✘-1 $ go run cmd/kn/main.go route describe he$low@rld
routes.serving.knative.dev "he@rld" not found
exit status 1
jordan at jordandembp.cn.ibm.com in ~/Work/workspace/go/src/github.com/knative/client [master|✔]
✘-1 $ go run cmd/kn/main.go route describe hello
routes.serving.knative.dev "hello" not found
exit status 1
So I also change the test route name to r@ute-that-d$es-n#t-exist for spceial case.
There was a problem hiding this comment.
I think we can rely on the error message from the API client to point in the right direction. I don't think we need an extra validation of the name on our side.
rhuss
left a comment
There was a problem hiding this comment.
Some minor comments around an unrealistic test. Otherwise looks good to me.
| t.Run("describe a valid route with default output", func(t *testing.T) { | ||
| setup(t) | ||
|
|
||
| action, output, err := fakeRouteDescribe([]string{"route", "describe", "test-foo"}, &expectedRoute) |
There was a problem hiding this comment.
So you are requesting a route with name "test-foo" but return a route with Route.Name == "foo". IMO the name you are are requesting and the returned name should be the same.
| validateGroupVersionKind(t, route) | ||
| }) | ||
|
|
||
| t.Run("get unknown route name returns error", func(t *testing.T) { |
There was a problem hiding this comment.
I think we can rely on the error message from the API client to point in the right direction. I don't think we need an extra validation of the name on our side.
|
The following is the coverage report on pkg/.
|
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: rhuss, zhangtbj The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
1, Implement kn route describe command with required parameters:
2, Add
gotest.toolstests for kn route describe commands:Also rebased from master and change to use new knClient.
For issue: #205