eventing
eventing copied to clipboard
Add `filters` to the trigger CRD
Problem
As trigger filters are an experimental feature, up until now they have not been included directly in the CRD as the API may have changed. However, with the feature relatively stable and in beta, we should start including the filters
field in the CRD for triggers.
Persona: Which persona is this feature for?
Exit Criteria
The trigger CRD has the filters
field included by default.
Time Estimate (optional): How many developer-days do you think this may take to resolve? 1
Additional context (optional)
/help /triage accepted
@Cali0707: This request has been marked as needing help from a contributor.
Please ensure the request meets the requirements listed here.
If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-help
command.
In response to this:
/help /triage accepted
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.
/assign erharjotsingh Hello @Cali0707 I can take this up. It will be great if you can kindly help with little more details about current and expected results example
Hi @erharjotsingh what we are looking to do is map the golang types that I linked above for the SubscriptionsApi Filters into a filters
field in the trigger CRD (also linked above). This would look similar to how the attribute filter maps into the filter
field in the trigger CRD. Let me know if you have any other questions!
Thanks @Cali0707 for clarifying. I am trying to look into it further. I will get back on this. Thanks!
hello @Cali0707 As per my understanding, we need to update file trigger.yaml like below: filter: type: object properties: attributes: type: object x-kubernetes-preserve-unknown-fields: true new filter: type: object x-kubernetes-preserve-unknown-fields: true
Please help me understand if this understanding is correct and kindly help to identify what all new fields new to be mapped. Thanks!
@erharjotsingh we need to add another filters
field alongside the filter
https://github.com/knative/eventing/blob/884f0da69566fff3fbc6003dc5a30b0bf943161e/config/core/resources/trigger.yaml#L120-L127
the filters
field is a JSON object with these fields https://github.com/knative/eventing/blob/884f0da69566fff3fbc6003dc5a30b0bf943161e/pkg/apis/eventing/v1/trigger_types.go#L123-L179
For example (more details needs to be added for objects types):
filters:
description: 'Filters is an experimental field that conforms to the CNCF CloudEvents Subscriptions API. It''s an array of filter expressions that evaluate to true or false. If any filter expression in the array evaluates to false, the event MUST NOT be sent to the Subscriber. If all the filter expressions in the array evaluate to true, the event MUST be attempted to be delivered. Absence of a filter or empty array implies a value of true. In the event of users specifying both Filter and Filters, then the latter will override the former. This will allow users to try out the effect of the new Filters field without compromising the existing attribute-based Filter and try it out on existing Trigger objects. '
type: array
items:
type: object
properties:
all:
description: 'All evaluates to true if all the nested expressions evaluate to true. It must contain at least one filter expression. '
type: array
items:
type: object
any:
description: 'Any evaluates to true if at least one of the nested expressions evaluates to true. It must contain at least one filter expression. '
type: array
items:
type: object
cesql:
description: 'CESQL is a CloudEvents SQL expression that will be evaluated to true or false against each CloudEvent. '
type: string
exact:
description: 'Exact evaluates to true if the values of the matching CloudEvents attributes MUST all exactly match with the associated value String specified (case-sensitive). The keys are the names of the CloudEvents attributes to be matched, and their values are the String values to use in the comparison. The attribute name and value specified in the filter express MUST NOT be empty strings. '
type: object
x-kubernetes-preserve-unknown-fields: true
not:
description: 'Not evaluates to true if the nested expression evaluates to false. '
type: object
prefix:
description: 'Prefix evaluates to true if the values of the matching CloudEvents attributes MUST all start with the associated value String specified (case sensitive). The keys are the names of the CloudEvents attributes to be matched, and their values are the String values to use in the comparison. The attribute name and value specified in the filter express MUST NOT be empty strings. '
type: object
x-kubernetes-preserve-unknown-fields: true
suffix:
description: 'Suffix evaluates to true if the values of the matching CloudEvents attributes MUST all end with the associated value String specified (case sensitive). The keys are the names of the CloudEvents attributes to be matched, and their values are the String values to use in the comparison. The attribute name and value specified in the filter express MUST NOT be empty strings. '
type: object
x-kubernetes-preserve-unknown-fields: true
hello @Cali0707 I have submitted a PR for this. Kindly let me know if we need to also update some docs. I can do that. Thanks! https://github.com/knative/eventing/pull/7930
hello @pierDipi @Cali0707 There seem to be some missing labels like approved, lgtm etc. due to which a few tests failed. Could you please guide me: https://prow.knative.dev/pr?query=is%3Apr%20state%3Aopen%20author%3Aerharjotsingh
hello @pierDipi @Cali0707 As test execution is successful, could you please review & approve the PR. Many thanks!