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 support for Eventing/v1beta2 EventTypes #1831

Merged
merged 5 commits into from
Jul 26, 2023

Conversation

dsimansk
Copy link
Contributor

@dsimansk dsimansk commented Jul 21, 2023

Description

Changes

  • Add support for Eventing/v1beta2 EventTypes

Reference

Fixes #

Release Note

Add support for Eventing/v1beta2 EventTypes with `--reference` option flag

/cc @rhuss @matzew

@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 21, 2023
Copy link

@knative-prow knative-prow bot left a comment

Choose a reason for hiding this comment

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

@dsimansk: 0 warnings.

In response to this:

Description

Changes

  • Add support for Eventing/v1beta2 EventTypes

Reference

Fixes #

Release Note

Add support for Eventing/v1beta2 EventTypes with `--reference` option flag

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 knative-prow bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jul 21, 2023
@codecov
Copy link

codecov bot commented Jul 23, 2023

Codecov Report

Patch coverage: 82.25% and project coverage change: -0.07% ⚠️

Comparison is base (3ecb24f) 79.73% compared to head (a0a2495) 79.66%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1831      +/-   ##
==========================================
- Coverage   79.73%   79.66%   -0.07%     
==========================================
  Files         179      179              
  Lines       13898    13946      +48     
==========================================
+ Hits        11081    11110      +29     
- Misses       2054     2069      +15     
- Partials      763      767       +4     
Files Changed Coverage Δ
pkg/kn/commands/eventtype/eventtype.go 100.00% <ø> (ø)
pkg/kn/commands/eventtype/create.go 75.34% <62.50%> (-12.16%) ⬇️
pkg/kn/commands/flags/sink.go 80.90% <68.96%> (-5.23%) ⬇️
pkg/eventing/v1beta2/client_mock.go 94.28% <93.75%> (ø)
pkg/eventing/v1beta2/client.go 85.00% <100.00%> (ø)
pkg/kn/commands/broker/delivery_option_flags.go 100.00% <100.00%> (ø)
pkg/kn/commands/completion_helper.go 85.54% <100.00%> (ø)
pkg/kn/commands/eventtype/delete.go 80.64% <100.00%> (ø)
pkg/kn/commands/eventtype/describe.go 81.25% <100.00%> (+2.30%) ⬆️
pkg/kn/commands/eventtype/list.go 80.26% <100.00%> (ø)
... and 2 more

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dsimansk dsimansk force-pushed the pr/eventtypes-v1beta2 branch 4 times, most recently from 0dd8833 to deee125 Compare July 23, 2023 21:27
@@ -37,6 +38,10 @@ const (
)

func TestEventtype(t *testing.T) {
//FIXME: enable after Eventing v1.11 is out
Copy link
Contributor

Choose a reason for hiding this comment

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

How can we ensure that we don't forget this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, it's a bit tedious. But the release is this week, I'll try not to foget to remove it immediately.

@@ -49,26 +57,32 @@ func (i *SinkFlags) AddWithFlagName(cmd *cobra.Command, fname, short string) {
"'" + flag + " ksvc:mysvc:mynamespace' for a Knative service 'mysvc' in another namespace 'mynamespace', " +
"'" + flag + " https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, " +
"'" + flag + " ksvc:receiver' or simply '" + flag + " receiver' for a Knative service 'receiver' in the current namespace. " +
"'" + flag + " special.eventing.dev/v1alpha1/channels:pipe' for GroupVersionResource of v1alpha1 'pipe'. " +
"GroupVersionResource requires resource name in a lower case plural form. The inputs are sanitized on best effort basis, " +
Copy link
Contributor

Choose a reason for hiding this comment

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

"requires resource name in a lower case plural form" --> Can't we do at least the lower casing on our own so that that case doesn't mind ? Also the plural form is not intuitive if you don't know about resources. I would accept also both, naively assuming that plural form mean adding a s (or is there an easier way to find out ?)

The overall help message now became quite a bit lengthy and since it is used for every sink type and some commands have multiple sink options (eg --sink, --sink-reply, --sink-dead-letter), the help page becomes too long.

We might:

  • Shorten it and reference to website for the full documentation.
  • Try to keep it but only keep the absolutely necessary information.

Eg. instead of

-s, --sink string               Addressable sink for events. You can specify a broker, channel, Knative service or URI. Examples: '--sink broker:nest' for a broker 'nest', '--sink channel:pipe' for a channel 'pipe', '--sink ksvc:mysvc:mynamespace' for a Knative service 'mysvc' in another namespace 'mynamespace', '--sink https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink ksvc:receiver' or simply '--sink receiver' for a Knative service 'receiver' in the current namespace. '--sink special.eventing.dev/v1alpha1/channels:pipe' for GroupVersionResource of v1alpha1 'pipe'. GroupVersionResource requires resource name in a lower case plural form. The inputs are sanitized on best effort basis, but in case of 'resource not found' error it may help to double check and correct the input. If a prefix is not provided, it is considered as a Knative service in the current namespace. If referring to a Knative service in another namespace, 'ksvc:name:namespace' combination must be provided explicitly.

we might use something like

-s, --sink string               Addressable sink for events. Use one of these formats: broker:<name>, channel:<name>, ksvc:<service>:<namespace>, <URI>, or simply <service>. Examples: '--sink broker:nest', '--sink ksvc:mysvc:mynamespace', '--sink https://event.receiver.uri', '--sink receiver'. If the prefix is omitted, it's assumed to be a Knative service in the current namespace. Also supports GroupVersionResource format like 'special.eventing.dev/v1alpha1/channels:pipe'. On errors like 'resource not found', verify your input format.

Copy link
Contributor Author

@dsimansk dsimansk Jul 24, 2023

Choose a reason for hiding this comment

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

I agree, it was a bit long even without this change. Sure, the code tries to do both lower case of course and add naive +s. However, we never explained anything from that. I kind of like the idea of a little how to use sinks page with a couple of examples.

Or I can move the plural form recommendation into error message maybe?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we might leave of the error explanation, too ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, let me remove the additional lines and keep just GVR example to check how that looks.

-h, --help help for create
-n, --namespace string Specify the namespace to operate in.
-r, --reference string Addressable Reference producing events. You can specify a broker, channel, or fully qualified GroupVersionResource (GVR). Examples: 'reference broker:nest' for a broker 'nest', 'reference channel:pipe' for a channel 'pipe', 'reference special.eventing.dev/v1alpha1/channels:pipe' for GroupVersionResource of v1alpha1 'pipe'.
Copy link
Contributor

Choose a reason for hiding this comment

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

Here the intial -- is missing for reference. Also maybe the short version would be nice (-r channel:pipe)

@@ -21,9 +21,10 @@ kn eventtype create
### Options

```
-b, --broker string Cloud Event broker
-b, --broker string Cloud Event Broker. This flag is added for the convenience, since Eventing v1beta2 brokers as represented as KReference type.
Copy link
Contributor

Choose a reason for hiding this comment

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

Still, I would remove the "is added for convenience" since this is an implementation detail that is confusing for a help page.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the whole sentence. Indeed it's an implementation detail.

@@ -26,7 +26,7 @@ kn source apiserver create NAME --resource RESOURCE --sink SINK
--resource stringArray Specification for which events to listen, in the format Kind:APIVersion:LabelSelector, e.g. "Event:sourcesv1:key=value".
"LabelSelector" is a list of comma separated key value pairs. "LabelSelector" can be omitted, e.g. "Event:sourcesv1".
--service-account string Name of the service account to use to run this source
-s, --sink string Addressable sink for events. You can specify a broker, channel, Knative service or URI. Examples: '--sink broker:nest' for a broker 'nest', '--sink channel:pipe' for a channel 'pipe', '--sink ksvc:mysvc:mynamespace' for a Knative service 'mysvc' in another namespace 'mynamespace', '--sink https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink ksvc:receiver' or simply '--sink receiver' for a Knative service 'receiver' in the current namespace. If a prefix is not provided, it is considered as a Knative service in the current namespace. If referring to a Knative service in another namespace, 'ksvc:name:namespace' combination must be provided explicitly.
-s, --sink string Addressable sink for events. You can specify a broker, channel, Knative service or URI. Examples: '--sink broker:nest' for a broker 'nest', '--sink channel:pipe' for a channel 'pipe', '--sink ksvc:mysvc:mynamespace' for a Knative service 'mysvc' in another namespace 'mynamespace', '--sink https://event.receiver.uri' for an URI with an 'http://' or 'https://' schema, '--sink ksvc:receiver' or simply '--sink receiver' for a Knative service 'receiver' in the current namespace. '--sink special.eventing.dev/v1alpha1/channels:pipe' for GroupVersionResource of v1alpha1 'pipe'. If a prefix is not provided, it is considered as a Knative service in the current namespace. If referring to a Knative service in another namespace, 'ksvc:name:namespace' combination must be provided explicitly.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would remove If referring to a Knative service in another namespace, 'ksvc:name:namespace' combination must be provided explicitly.

Copy link
Contributor

Choose a reason for hiding this comment

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

with an 'http://' or 'https://' schema might be overkill. Maybe only "for an HTTP URI" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@rhuss can we merge it? asking because we're in a release day already.

@dsimansk
Copy link
Contributor Author

@knative/knative-release-leads FYI this should be merged for v1.11 release.

@rhuss
Copy link
Contributor

rhuss commented Jul 26, 2023

Looks good to me, I added a final comment to the wording. Feel free to merge nevertheless.

/approve
/lgtm
/hold

@knative-prow knative-prow bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 26, 2023
@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jul 26, 2023
@knative-prow knative-prow bot removed the lgtm Indicates that a PR is ready to be merged. label Jul 26, 2023
@rhuss
Copy link
Contributor

rhuss commented Jul 26, 2023

/approve
/lgtm

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jul 26, 2023
@knative-prow
Copy link

knative-prow bot commented Jul 26, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dsimansk, 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

@dsimansk
Copy link
Contributor Author

/unhold

@knative-prow knative-prow bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 26, 2023
@knative-prow knative-prow bot merged commit 3a7d8c1 into knative:main Jul 26, 2023
23 checks passed
@dsimansk dsimansk linked an issue Jul 26, 2023 that may be closed by this pull request
@dsimansk dsimansk added the kind/feature New feature or request label Jul 26, 2023
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. kind/feature New feature or request lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI: Add support for EventType v1beta2
2 participants