eventing icon indicating copy to clipboard operation
eventing copied to clipboard

Event Discovery: Add Variables to EventType V1Beta3 spec

Open Cali0707 opened this issue 11 months ago • 9 comments

Problem In the new v1beta3 api for eventtypes, we are allowing users to place "variables" into template strings for the various eventtype attributes. It would be good to allow users to give more information about what values are allowed for those variables.

To accomplish this, we can add a variables section to the spec like this:

apiVersion: eventing.knative.dev/v1beta3
kind: EventType
spec:
  reference:
    ...
  attributes:
    - name: "type"
      value: "event.{requestStatus}.foo"
      required: true
    ...
  variables:
    - name: "requestStatus"
      pattern: "req_est.%"
      example: "request.failed"

Cali0707 avatar Feb 27 '24 16:02 Cali0707

cc @pierDipi @matzew @dsimansk

I'd love to get some feedback on this idea

Cali0707 avatar Feb 27 '24 16:02 Cali0707

@pierDipi can we discuss this at the WG call this week? I need a decision on how we are planning to proceed here for #7883

Cali0707 avatar Apr 30 '24 18:04 Cali0707

Was there any outcome on that discussion?

matzew avatar Jun 25 '24 14:06 matzew

@matzew I think the decision was that we would aim to include this, as long as people were happy with the API. Any thoughts on the API proposed here/anything you would change?

Cali0707 avatar Jun 25 '24 14:06 Cali0707

Any thoughts on the API proposed here/anything you would change?

  attributes:
    - name: "type"
      value: "event.{requestStatus}.foo"
      required: true
    ...
  variables:
    - name: "requestStatus"
      regex: "[a-zA-Z]"
      example: "request.failed"

so for reconciling these, we would expect that if {variables} are used, it MUST have variables section, containing those that are specified. Otherwise: not getting to ready state.

For the implementation, I guess we could just rely on simple regex library? Should we prevent some parts? Expressions and templating always causes hell of problems. Does CE-SQL have something?

matzew avatar Jun 25 '24 14:06 matzew

so for reconciling these, we would expect that if {variables} are used, it MUST have variables section, containing those that are specified. Otherwise: not getting to ready state.

Yeah, I think that makes sense to me, we might also want to verify that the example in the variable is allowable based on the pattern for the variable

Does CE-SQL have something?

For CESQL, it doesn't support full regex matches instead it allows for a wildcard character % that matches any number of wildcard characters and another wildcard character _ that matches exactly one wildcard character. This would simplify the templating allowed for the variables a lot I think, which should make it easier to manage.

Cali0707 avatar Jun 25 '24 14:06 Cali0707

Yeah, I think that makes sense to me, we might also want to verify that the example in the variable is allowable based on the pattern for the variable

I agree, so we have a set of "scoped" rules

This would simplify the templating allowed for the variables a lot I think, which should make it easier to manage.

some reuse possible?

matzew avatar Jun 25 '24 15:06 matzew

Yeah I think the reuse would make this easier, and also would make implementing the event lineage matches easier too! I've updated the proposed API to have the pattern match the CESQL syntax, instead of being a regex. @matzew @pierDipi are we good to move forwards with this?

Cali0707 avatar Jun 28 '24 18:06 Cali0707

@pierDipi quick ping here - are you good with moving forwards with the CESQL LIKE syntax here?

Cali0707 avatar Jul 29 '24 23:07 Cali0707