Skip to content

Fix issue #205 to add route describe feature and test#228

Closed
zhangtbj wants to merge 0 commit intoknative:masterfrom
zhangtbj:master
Closed

Fix issue #205 to add route describe feature and test#228
zhangtbj wants to merge 0 commit intoknative:masterfrom
zhangtbj:master

Conversation

@zhangtbj
Copy link
Copy Markdown
Contributor

@zhangtbj zhangtbj commented Jul 5, 2019

1, Implement kn route describe command with required parameters:

✔ $ go run cmd/kn/main.go route describe --help
Describe available route.

Usage:
  kn route describe NAME [flags]

Flags:
      --allow-missing-template-keys   If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. (default true)
  -h, --help                          help for describe
  -n, --namespace string              List the requested object(s) in given namespace.
  -o, --output string                 Output format. One of: json|yaml|name|go-template|go-template-file|template|templatefile|jsonpath|jsonpath-file. (default "yaml")
      --template string               Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].

Global Flags:
      --config string       config file (default is $HOME/.kn/config.yaml)
      --kubeconfig string   kubectl config file (default is $HOME/.kube/config)

2, Add gotest.tools tests for kn route describe commands:

  • test without route name
  • test route describe with the default output
  • test route describe with the YAML output
  • test route describe with the JSON output
  • test route describe with the name output

For issue: #205

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Jul 5, 2019
@knative-prow-robot
Copy link
Copy Markdown
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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.

@knative-prow-robot knative-prow-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 5, 2019
@zhangtbj
Copy link
Copy Markdown
Contributor Author

zhangtbj commented Jul 5, 2019

/assign @maximilie

@knative-prow-robot
Copy link
Copy Markdown
Contributor

@zhangtbj: GitHub didn't allow me to assign the following users: maximilie.

Note that only knative members and repo collaborators can be assigned and that issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

Details

In response to this:

/assign @maximilie

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.

@maximilien
Copy link
Copy Markdown
Contributor

/ok-to-test

@knative-prow-robot knative-prow-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 5, 2019
@knative-metrics-robot
Copy link
Copy Markdown

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

File Old Coverage New Coverage Delta
pkg/kn/commands/route/route_describe.go Do not exist 79.2%
pkg/kn/commands/route/route_list.go Do not exist 76.7%
pkg/kn/commands/route/route_list_flags.go Do not exist 66.7%

}

t.Run("requires the route name", func(t *testing.T) {
_, _, err := fakeRouteDescribe([]string{"route", "describe"}, &v1alpha1.Route{})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is setup(t) not called here? Perhaps do it for consistency

Copy link
Copy Markdown
Contributor Author

@zhangtbj zhangtbj Jul 5, 2019

Choose a reason for hiding this comment

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

Hi Max, because this test is only for wihtout route name test. So doesn't need to initialize any fake route in setup. So I skip it. If we hope to be consistent. I can add it back. Thanks!

assert.Assert(t, err == nil)
assert.Assert(t, action != nil)
assert.Assert(t, action.Matches("get", "routes"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure I see the value of JSON conversion here. Why not just parse the YAML returned (it’s the default output)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, in this test, I parse to json format and Unmarshal it to a route object returnedRoute. Then compare it with expectedRoute

@maximilien
Copy link
Copy Markdown
Contributor

Nice job @zhangtbj left a few minor comments. Adding @navidshaikh as reviewer too.

@maximilien
Copy link
Copy Markdown
Contributor

/assign @navidshaikh

@knative-prow-robot
Copy link
Copy Markdown
Contributor

@maximilien: GitHub didn't allow me to assign the following users: navidshaikh.

Note that only knative members and repo collaborators can be assigned and that issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

Details

In response to this:

/assign @navidshaikh

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.

@rhuss
Copy link
Copy Markdown
Contributor

rhuss commented Jul 5, 2019

@zhangtbj coudl you please rebase on master ? Gotest.tools is already included on master but also part of this PR. This should not be the case.

Comment thread pkg/kn/commands/route/route_describe.go Outdated
if err != nil {
return err
}
describeRoute.GetObjectKind().SetGroupVersionKind(schema.GroupVersionKind{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we please get #134 merged first as this directly is changed in this PR ?

I mark this PR as 'on-hold' if this ok, and remove it if we have #134 in place. 'hope this is ok.

Comment thread pkg/kn/commands/route/route_describe.go Outdated
return err
}
describeRoute.GetObjectKind().SetGroupVersionKind(schema.GroupVersionKind{
Group: "knative.dev",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

its the wrong group anyway, but that gets fixed with #134.

Copy link
Copy Markdown
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 for the PR ! Technical its ok (except the missing rebase on master), but we should really agree what <noun> describe shoulde:

  • Should it, like for kubectl, only be targetting human-readable output ? (there is no -o option for 'kubectl describe')
  • Should -o yaml|json|name be exclusively reserved for kn revision list (with kubectl get being the equivalent for kubectl) ? Or is it ok to have it for kn revision describe to ?
  • Would be we good to rename describe to show to make the deviation to kubectl more clear ? We already went from get to list so moving from describe to show would be consiquent (and it would be then also easier to deviate from kubectl describe behaviour like adding -o options).

@maximilien @sixolet @cppforlife @navidshaikh any opinions on this ?

Comment thread pkg/kn/commands/route/route_describe.go Outdated
Group: "knative.dev",
Version: "v1alpha1",
Kind: "Route"})
err = printer.PrintObj(describeRoute, cmd.OutOrStdout())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

'route describe' (or as I would love to rename it to 'route show', but that's another discussion ;) should imo really be about human readable output. I think its ok to have -o name|json|yaml, too but the main focus is to have a detaile out of the the routes, what revisions they are targetting which with which split and which service the route is targetting.

See #75 for the idea (although this PR is too huge and as soon as #134 is merged it will be broken down).

@navidshaikh
Copy link
Copy Markdown
Contributor

@zhangtbj : Thanks for your PR.
show (or describe verb) for a resource should print better representation of a resource's detailed info as compare to printing yaml for same. This is the reason we have revision describe #206 open.

Please check work done by @rhuss on #75 , we'd like to produce something like that. I'd say lets discuss info we'd like show for route show or describe on the issue.

@rhuss
Copy link
Copy Markdown
Contributor

rhuss commented Jul 5, 2019

I opened #235 for discussion the general direction we want to go with kn <noun> show (or kn <noun> describe)

@maximilien
Copy link
Copy Markdown
Contributor

maximilien commented Jul 8, 2019

@rhuss are we adding this to discussion tomorrow or do we already have too much?

In any case, let's make sure to document decision(s) in WG doc or here as @zhangtbj is in Beijing and the time for the meeting is 1:30a so it's not clear he can attend in person.

@googlebot
Copy link
Copy Markdown

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: no Indicates the PR's author has not signed the CLA. and removed cla: yes Indicates the PR's author has signed the CLA. labels Jul 9, 2019
@zhangtbj zhangtbj closed this Jul 9, 2019
@knative-prow-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: zhangtbj

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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 added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 9, 2019
@zhangtbj
Copy link
Copy Markdown
Contributor Author

zhangtbj commented Jul 9, 2019

Sorry I closed this PR by mistake. I created a new PR #251 which is rebased from master and change to use new knClient. Thanks!

dsimansk pushed a commit to dsimansk/client that referenced this pull request Feb 6, 2024
…y providing goos and goarch. (knative#228)

* add go build with goos and goarch

* add a example at help message

---------

Co-authored-by: Kaustubh Pande <kaustubhpande.kp@gmail.com>
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: no Indicates the PR's author has not signed the CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants