-
Notifications
You must be signed in to change notification settings - Fork 605
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
Update eventtype v1beta3 type to reflect spec changes #7708
Conversation
Signed-off-by: Calum Murray <[email protected]>
Signed-off-by: Calum Murray <[email protected]>
Signed-off-by: Calum Murray <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7708 +/- ##
==========================================
+ Coverage 69.04% 69.22% +0.17%
==========================================
Files 338 339 +1
Lines 19350 19494 +144
==========================================
+ Hits 13360 13494 +134
- Misses 5328 5337 +9
- Partials 662 663 +1 ☔ View full report in Codecov by Sentry. |
type EventAttributeDefinition struct { | ||
// Required determines whether this attribute must be set on corresponding CloudEvents. | ||
Required bool `json:"required"` | ||
// Value is a string representing the allowable values for the EventType attribute. | ||
// It may be a single value such as "/apis/v1/namespaces/default/pingsource/ps", or it could be a template | ||
// for the allowed values, such as "/apis/v1/namespaces/{namespace}/pingsource/{sourceName}. | ||
// To specify a section of the string value which may change between different CloudEvents | ||
// you can use curly brackets {} and optionally a variable name between them. | ||
Value string `json:"value,omitempty"` |
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.
I'd argue that the original proposed name
is useful, to identify what the attr def is is about, is useful. see:
spec:
attributes:
- name: type
value: com.shop.domain.order.new
required: true
- name: specversion
value: "1.0"
- name: id
required: true
- name: source
value: "/customer-system/node/some-id-value"
- name: time
required: true
- name: myextension
required: false
...
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.
That makes sense @matzew , I was basing this off of your earlier WIP PR, where I think this would end up mapping to a CRD like:
spec:
attributes:
type:
value: com.shop.domain.order.new
required: true
specversion:
value: "1.0"
...
If you think the proposed version with name
makes more sense, I'm happy to update this to reflect that idea instead - I just had guessed that the PR was a "newer" version of the idea than the issue :)
Signed-off-by: Calum Murray <[email protected]>
Signed-off-by: Calum Murray <[email protected]>
@@ -22,6 +22,132 @@ metadata: | |||
spec: | |||
group: eventing.knative.dev | |||
versions: | |||
- name: v1beta3 | |||
served: false |
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.
The new version is not served as a precaution for now?
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.
Yeah, I figured we could serve it when we update the reconciler to reconcile the new type
Name string `json:"name"` | ||
// Required determines whether this attribute must be set on corresponding CloudEvents. | ||
Required bool `json:"required"` | ||
// Value is a string representing the allowable values for the EventType attribute. |
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.
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.
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.
@Cali0707 thanks for taking over this part! Looks good to me, I've added 2 question in the review, but none is a blocker to be resolved for the merge.
Adding hold for other reviews.
/hold
Schema: testSchema, | ||
Attributes: []EventAttributeDefinition{ | ||
EventAttributeDefinition{ | ||
Value: "test-type", |
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.
would name
not also really make sense here?
should we require name? for the attr def?
Signed-off-by: Calum Murray <[email protected]>
items: | ||
type: object | ||
required: | ||
- name |
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.
isn't value
also required ?
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.
Not currently, no. Currently you can just add a name
and whether or not that attribute is required without specifying what value it may have. I think of this as a way of saying "the event may have attribute xyz
". But, I could understand making this field required too. WDYT we should do @pierDipi ?
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.
yes, that is exactly what I was thinking too. IMO this is useful for "extensions",
the following is IMO valid:
- name: myextension
required: false
while some attribute names are requied to have a value (e.g. all the CE "required" attrs)
config/core/resources/eventtype.yaml
Outdated
jsonPath: ".spec.attributes.type.value" | ||
- name: Source | ||
type: string | ||
jsonPath: ".spec.attributeds.source.value" |
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.
I don't see these 2 attributes
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.
Oh yeah good catch! I wrote these when we were using a map to hold all the attributes, rather than an array
Signed-off-by: Calum Murray <[email protected]>
/cc @pierDipi |
/test reconciler-tests |
if _, ok := attributes["specversion"]; !ok { | ||
missingFields = append(missingFields, "specversion") | ||
} | ||
if _, ok := attributes["id"]; !ok { | ||
missingFields = append(missingFields, "id") | ||
} |
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.
I'm wondering that to make the usage easier we could have id
and specversion
be optional even if it's technically required
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.
but I think starting with required is fine as making it optional would be a non-breaking change while the opposite is not true
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.
That makes sense to me, especially if id
is going to just be a UUID, and specversion will probably just be 1.0
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: Cali0707, dsimansk, 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 |
/unhold |
/test reconciler-tests |
/test reconciler-tests |
@Cali0707: The following test failed, say
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. I understand the commands that are listed here. |
/test reconciler-tests |
Part of #7265
Proposed Changes