-
Notifications
You must be signed in to change notification settings - Fork 109
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
Implement new trigger filters experimental feature (SubscriptionsAPI Filters) #1922
Implement new trigger filters experimental feature (SubscriptionsAPI Filters) #1922
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1922 +/- ##
============================================
+ Coverage 66.98% 67.23% +0.24%
- Complexity 630 632 +2
============================================
Files 140 141 +1
Lines 6567 6687 +120
Branches 179 180 +1
============================================
+ Hits 4399 4496 +97
- Misses 1800 1823 +23
Partials 368 368
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
/rebase |
does that really work ? 😂 |
...ava/dev/knative/eventing/kafka/broker/dispatcher/impl/filter/subscriptionsapi/AllFilter.java
Show resolved
Hide resolved
...ain/java/dev/knative/eventing/kafka/broker/core/reconciler/impl/ResourcesReconcilerImpl.java
Outdated
Show resolved
Hide resolved
I think, as said on the other PR this looks good I had only a nit, do to import/format changes. |
9fa00ee
to
d730363
Compare
...main/java/dev/knative/eventing/kafka/broker/dispatcher/main/ConsumerVerticleFactoryImpl.java
Outdated
Show resolved
Hide resolved
LGTM, as already stated on the other PR. |
// https://github.com/cloudevents/spec/blob/main/subscriptions/spec.md#any-filter-dialect | ||
func NewAnyFilter(filters []v1.SubscriptionsAPIFilter) *DialectedFilter { | ||
any := Any{ | ||
Filters: []*DialectedFilter{}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filters: []*DialectedFilter{}, | |
Filters: make(DialectedFilter, 0, len(filters)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
// https://github.com/cloudevents/spec/blob/main/subscriptions/spec.md#all-filter-dialect | ||
func NewAllFilter(filters []v1.SubscriptionsAPIFilter) *DialectedFilter { | ||
all := All{ | ||
Filters: []*DialectedFilter{}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can pre-allocate this array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
// NewExactFilter converts the SubscriptionsAPIFilter into the exact dialect of | ||
// the DialectedFilter as defined in CloudEvents Subscriptions API. | ||
// | ||
// Exact contains exactly one attribute where the key is the name of the CloudEvent | ||
// attribute and its value is the string value which must exactly match the value | ||
// of the CloudEvent attribute. | ||
// | ||
// See "CNCF CloudEvents Subscriptions API" > "3.2.4.1 Filters Dialects" | ||
// https://github.com/cloudevents/spec/blob/main/subscriptions/spec.md#all-filter-dialect | ||
func NewExactFilter(f v1.SubscriptionsAPIFilter) *DialectedFilter { | ||
return &DialectedFilter{ | ||
Filter: &DialectedFilter_Exact{ | ||
Exact: &Exact{ | ||
Attributes: f.Exact, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
// NewPrefixFilter converts the SubscriptionsAPIFilter into the suffix dialect of | ||
// the DialectedFilter as defined in CloudEvents Subscriptions API. | ||
// | ||
// Prefix contains exactly one attribute where the key is the name of the CloudEvent | ||
// attribute which value must start with the value specified. | ||
// | ||
// See "CNCF CloudEvents Subscriptions API" > "3.2.4.1 Filters Dialects" | ||
// https://github.com/cloudevents/spec/blob/main/subscriptions/spec.md#prefix-filter-dialect | ||
func NewPrefixFilter(f v1.SubscriptionsAPIFilter) *DialectedFilter { | ||
|
||
p := &Prefix{} | ||
// Eventing Trigger API is conforming to the Subscriptions API, so this map has only a single | ||
// key-value pair | ||
for k, v := range f.Prefix { | ||
p.Attribute = k | ||
p.Prefix = v | ||
// We only expect a single element, but let's break anyway | ||
break | ||
} | ||
|
||
return &DialectedFilter{ | ||
Filter: &DialectedFilter_Prefix{ | ||
Prefix: p, | ||
}, | ||
} | ||
} | ||
|
||
// NewSuffixFilter converts the SubscriptionsAPIFilter into the suffix dialect of | ||
// the DialectedFilter as defined in CloudEvents Subscriptions API. | ||
// | ||
// Suffix contains exactly one attribute where the key is the name of the CloudEvent | ||
// attribute which value must end with the value specified. | ||
// | ||
// See "CNCF CloudEvents Subscriptions API" > "3.2.4.1 Filters Dialects" | ||
// https://github.com/cloudevents/spec/blob/main/subscriptions/spec.md#suffix-filter-dialect | ||
func NewSuffixFilter(f v1.SubscriptionsAPIFilter) *DialectedFilter { | ||
|
||
p := &Suffix{} | ||
// Eventing Trigger API is conforming to the Subscriptions API, so this map has only a single | ||
// key-value pair | ||
for k, v := range f.Suffix { | ||
p.Attribute = k | ||
p.Suffix = v | ||
// We only expect a single element, but let's break anyway | ||
break | ||
} | ||
|
||
return &DialectedFilter{ | ||
Filter: &DialectedFilter_Suffix{ | ||
Suffix: p, | ||
}, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the other comment on the PR, there shouldn't be a difference between these 3 filters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
func FromSubscriptionFilter(f v1.SubscriptionsAPIFilter) *DialectedFilter { | ||
switch { | ||
case len(f.All) > 0: | ||
return NewAllFilter(f.All) | ||
case len(f.Any) > 0: | ||
return NewAnyFilter(f.Any) | ||
case f.Not != nil: | ||
return NewNotFilter(*f.Not) | ||
case f.Exact != nil: | ||
return NewExactFilter(f) | ||
case f.Prefix != nil: | ||
return NewPrefixFilter(f) | ||
case f.Suffix != nil: | ||
return NewSuffixFilter(f) | ||
case f.SQL != "": | ||
return NewCESQLFilter(f) | ||
} | ||
return &DialectedFilter{} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we decouple the one filter constraint from the contract?
I remember making this comment in another PR 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition, the CE subscription spec doesn't have this constraint, so I would really avoid designing a contract in this way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we decouple the one filter constraint from the contract? I remember making this comment in another PR thinking
Yes I'm working on it.
In addition, the CE subscription spec doesn't have this constraint
Yeah while it's not in the spec itself, it's in the reference openapi file and I remember that it was brought up in one of the PRs introducing the spec. But I agree that we shouldn't have it tightly coupled here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
...dev/knative/eventing/kafka/broker/dispatcher/impl/filter/subscriptionsapi/SqlFilterTest.java
Outdated
Show resolved
Hide resolved
.../knative/eventing/kafka/broker/dispatcher/impl/filter/subscriptionsapi/SuffixFilterTest.java
Outdated
Show resolved
Hide resolved
.../knative/eventing/kafka/broker/dispatcher/impl/filter/subscriptionsapi/PrefixFilterTest.java
Outdated
Show resolved
Hide resolved
...v/knative/eventing/kafka/broker/dispatcher/impl/filter/subscriptionsapi/ExactFilterTest.java
Outdated
Show resolved
Hide resolved
...ain/java/dev/knative/eventing/kafka/broker/core/reconciler/impl/ResourcesReconcilerImpl.java
Show resolved
Hide resolved
/unhold |
Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>
Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>
Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>
Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>
Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>
Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>
Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>
Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>
Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>
Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>
Signed-off-by: Ahmed Abdalla <aabdelre@redhat.com>
The following is the coverage report on the affected files.
|
Seems like the webhook was unavailable
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aliok, devguyio, pierDipi 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 |
/cherry-pick release-1.3 |
@devguyio: new pull request created: #2008 In response to this:
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. |
Implementation of the new filters experimental feature
Based on #1921 , #1977 & #1978
Fixes #1763
Proposed Changes
TODO
Release Note