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

Add command group for ContainerSource #1016

Merged
merged 6 commits into from
Dec 2, 2020

Conversation

daisy-ycguo
Copy link
Member

@daisy-ycguo daisy-ycguo commented Sep 17, 2020

Description

Add command groups for container source, including

  • create container source
  • delete container source
  • update container source
  • list container source
  • describe container source

Reference

Fixes #809

@knative-prow-robot knative-prow-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 17, 2020
@knative-prow-robot knative-prow-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Sep 17, 2020
@daisy-ycguo daisy-ycguo changed the title [WIP] Add command groups for creating and deleting of ContainerSource [WIP] Add commands for creating and deleting of ContainerSource Sep 17, 2020
@daisy-ycguo daisy-ycguo changed the title [WIP] Add commands for creating and deleting of ContainerSource [WIP] Add commands for creating and deleting ContainerSource Sep 17, 2020
@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Sep 17, 2020
Copy link
Contributor

@maximilien maximilien 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 contribution. Obviously you are missing tests so this is just quick review for initial feedback.

One key thing that I feel (and may be wrong) is whether some parts of this PR (e.g., flags parsing for env options and others) is not common to other commands? If it is can we avoid duplication?

Thanks.

pkg/kn/commands/source/container/container.go Outdated Show resolved Hide resolved
pkg/kn/commands/source/container/create.go Outdated Show resolved Hide resolved
pkg/kn/flags/podspec.go Outdated Show resolved Hide resolved
pkg/kn/flags/podspec.go Outdated Show resolved Hide resolved
pkg/sources/v1alpha2/container_client.go Outdated Show resolved Hide resolved
@daisy-ycguo
Copy link
Member Author

Thanks for contribution. Obviously you are missing tests so this is just quick review for initial feedback.

One key thing that I feel (and may be wrong) is whether some parts of this PR (e.g., flags parsing for env options and others) is not common to other commands? If it is can we avoid duplication?

Thanks.

Some of the flag handling is common with the flag handling of service commands group. It also contains a big refactor. Just in order to ease the review, I will submit another PR to refactor the service commands group.

@daisy-ycguo daisy-ycguo force-pushed the container branch 2 times, most recently from c1598b6 to 096ae12 Compare September 22, 2020 11:47
@daisy-ycguo daisy-ycguo changed the title [WIP] Add commands for creating and deleting ContainerSource Add commands for creating and deleting ContainerSource Sep 22, 2020
@knative-prow-robot knative-prow-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 22, 2020
@rhuss
Copy link
Contributor

rhuss commented Sep 29, 2020

@daisy-ycguo the PR is really cool, I think we should continue to work on this to get it ready for 0.18

I think the coverage is still a bit low.

@dsimansk could you give this PR a review ? That would be really awesome !

@daisy-ycguo daisy-ycguo force-pushed the container branch 2 times, most recently from 0076ce4 to 9239aa6 Compare October 22, 2020 07:44
@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 27, 2020
@dsimansk
Copy link
Contributor

@rhuss sorry I've missed the first ping that was long time ago. I'll definitely take a look and review the PR.

@knative-prow-robot knative-prow-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Nov 3, 2020
Copy link
Contributor

@maximilien maximilien left a comment

Choose a reason for hiding this comment

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

Some comments.

Also, any change for a e2e test? Important since that’s a feature tying multiple parts of the system. OK to do so as a separate PR.

pkg/kn/commands/source/container/container_test.go Outdated Show resolved Hide resolved
pkg/kn/commands/source/container/list.go Outdated Show resolved Hide resolved
@daisy-ycguo daisy-ycguo changed the title Add commands for creating and deleting ContainerSource Add command group for ContainerSource Nov 4, 2020
@daisy-ycguo
Copy link
Member Author

Some comments.

Also, any change for a e2e test? Important since that’s a feature tying multiple parts of the system. OK to do so as a separate PR.

Let me try to do e2e in this PR. Thank you for reminder.

Comment on lines +27 to +29
v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2"
"knative.dev/eventing/pkg/client/clientset/versioned/scheme"
clientv1alpha2 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2"
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we can aim for v1 here rather than v1alpha2, since it's available on current Eventing master. Therefore it will be in 0.19 release.

https://github.com/knative/eventing/blob/master/pkg/apis/sources/v1/container_types.go

Copy link
Member Author

Choose a reason for hiding this comment

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

Good suggestion. I will suggest we upgrade all build-in sources (ApiServerSource, SinkBinding and ContainerSource) from v1alpha2 to v1 in another PR.
I don't see much difference in container sources between v1alpha2 and v1. We need to check the spec for other two build-in sources. Agree ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I have had a similar question to Navid that he actually replied to that it's fine to use older API as we want to support it until it goes away.

/cc @navidshaikh am I right here? :)

Copy link
Member Author

@daisy-ycguo daisy-ycguo Dec 2, 2020

Choose a reason for hiding this comment

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

I created an issue #1160. Let's do the upgrade in following PRs. Currently, Kn Client support only 1 version of Eventing sources, that is v1alpha2. We might not want to support v1alpha2 of apiserversource, sinkbinding and pingsource, while another version of container source.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, we are following the "defensive" approach as described in #462

Copy link
Contributor

@maximilien maximilien left a comment

Choose a reason for hiding this comment

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

/retest

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 16, 2020
@daisy-ycguo daisy-ycguo force-pushed the container branch 2 times, most recently from 48fd3a6 to 0c910c6 Compare November 17, 2020 14:40
Copy link
Contributor

@maximilien maximilien left a comment

Choose a reason for hiding this comment

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

/retest

@daisy-ycguo daisy-ycguo force-pushed the container branch 2 times, most recently from 829b924 to 1653c14 Compare November 18, 2020 08:21
@daisy-ycguo
Copy link
Member Author

daisy-ycguo commented Nov 18, 2020

@navidshaikh @dsimansk @maximilien
Hello, this PR is finally completed, including the whole container commands and e2e test. Sorry it took such a long time. Please help to review. I will address any comments from you. Thank you.

Copy link
Contributor

@dsimansk dsimansk left a comment

Choose a reason for hiding this comment

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

@daisy-ycguo looks good!
I've added a few comments though, mostly around function's return handling, but those are rather cosmetic ones.

Comment on lines 86 to 90
if err == nil {
fmt.Fprintf(cmd.OutOrStdout(), "ContainerSource '%s' created in namespace '%s'.\n", args[0], namespace)
}

return err
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd remove the explicit if err == nil check since it's going to be always true due to the condition above.

Suggested change
if err == nil {
fmt.Fprintf(cmd.OutOrStdout(), "ContainerSource '%s' created in namespace '%s'.\n", args[0], namespace)
}
return err
fmt.Fprintf(cmd.OutOrStdout(), "ContainerSource '%s' created in namespace '%s'.\n", args[0], namespace)
return nil

Copy link
Member Author

Choose a reason for hiding this comment

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

Good suggestions. Thank you. I changed in the new version.

listFlags.EnsureWithNamespace()
}

err = listFlags.Print(sourceList, cmd.OutOrStdout())
Copy link
Contributor

@dsimansk dsimansk Nov 30, 2020

Choose a reason for hiding this comment

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

The following would be sufficient here. Just return here and remove the rest of code below.

Suggested change
err = listFlags.Print(sourceList, cmd.OutOrStdout())
return listFlags.Print(sourceList, cmd.OutOrStdout())

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. Fixed.

Comment on lines 90 to 95
err = srcClient.UpdateContainerSource(b.Build())
if err == nil {
fmt.Fprintf(cmd.OutOrStdout(), "Container source '%s' updated in namespace '%s'.\n", args[0], namespace)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This kind of breaks the code flow of code for me. Maybe we could first check if err != nil and display similar message error message like in create op.

Copy link
Member Author

Choose a reason for hiding this comment

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

Changed in the new version.

Comment on lines +27 to +29
v1alpha2 "knative.dev/eventing/pkg/apis/sources/v1alpha2"
"knative.dev/eventing/pkg/client/clientset/versioned/scheme"
clientv1alpha2 "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2"
Copy link
Contributor

Choose a reason for hiding this comment

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

I have had a similar question to Navid that he actually replied to that it's fine to use older API as we want to support it until it goes away.

/cc @navidshaikh am I right here? :)

@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/commands/source/container/container.go Do not exist 59.1%
pkg/kn/commands/source/container/create.go Do not exist 84.4%
pkg/kn/commands/source/container/delete.go Do not exist 82.4%
pkg/kn/commands/source/container/describe.go Do not exist 58.6%
pkg/kn/commands/source/container/human_readable_flags.go Do not exist 52.4%
pkg/kn/commands/source/container/list.go Do not exist 82.4%
pkg/kn/commands/source/container/update.go Do not exist 78.9%
pkg/sources/v1alpha2/container_client.go Do not exist 89.5%
pkg/sources/v1alpha2/container_client_mock.go Do not exist 90.9%

Copy link
Contributor

@dsimansk dsimansk left a comment

Choose a reason for hiding this comment

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

Thanks @daisy-ycguo looks OK now.
/approve
/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: daisy-ycguo, dsimansk, maximilien

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 45162fb into knative:master Dec 2, 2020
rhuss added a commit to rhuss/knative-client that referenced this pull request Mar 9, 2021
David meets all criteria for an approver:

- [x] Reviewer for at least 3 months
- [x] Primary reviewer for at least 10 substantial PRs to the codebase, e.g.
  * knative#1246
  * knative#1194
  * knative#738
  * knative#832
  * knative#1016
  * knative#877
  * knative#667
  * knative#697
  * knative#1212
  * knative#835
- [x] Reviewed at least 30 PRs to the codebase ([38 assigned PRs](https://github.com/knative/client/pulls?q=type%3Apr+assignee%3Adsimansk+))
- [x] Nominated by a WG lead (rhuss)

Congrats David ! Thanks a lot for your awesome work & contributions.
@rhuss rhuss mentioned this pull request Mar 9, 2021
4 tasks
rhuss added a commit to rhuss/knative-client that referenced this pull request Mar 9, 2021
David meets all criteria for an approver:

- [x] Reviewer for at least 3 months
- [x] Primary reviewer for at least 10 substantial PRs to the codebase, e.g.
  * knative#1246
  * knative#1194
  * knative#738
  * knative#832
  * knative#1016
  * knative#877
  * knative#667
  * knative#697
  * knative#1212
  * knative#835
- [x] Reviewed at least 30 PRs to the codebase ([38 assigned PRs](https://github.com/knative/client/pulls?q=type%3Apr+assignee%3Adsimansk+))
- [x] Nominated by a WG lead (rhuss)

Congrats David ! Thanks a lot for your awesome work & contributions.
knative-prow-robot pushed a commit that referenced this pull request Mar 9, 2021
David meets all criteria for an approver:

- [x] Reviewer for at least 3 months
- [x] Primary reviewer for at least 10 substantial PRs to the codebase, e.g.
  * #1246
  * #1194
  * #738
  * #832
  * #1016
  * #877
  * #667
  * #697
  * #1212
  * #835
- [x] Reviewed at least 30 PRs to the codebase ([38 assigned PRs](https://github.com/knative/client/pulls?q=type%3Apr+assignee%3Adsimansk+))
- [x] Nominated by a WG lead (rhuss)

Congrats David ! Thanks a lot for your awesome work & contributions.
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. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for ContainerSource
8 participants