-
Notifications
You must be signed in to change notification settings - Fork 590
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
feat:added format flag #8080
feat:added format flag #8080
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,11 @@ type DeliverySpec struct { | |
// | ||
// +optional | ||
RetryAfterMax *string `json:"retryAfterMax,omitempty"` | ||
|
||
//Format supports more destinations of cloudevents (which may require a specific event format) | ||
// +optional | ||
|
||
Format *string `json:"format,omitempty"` | ||
} | ||
|
||
func (ds *DeliverySpec) Validate(ctx context.Context) *apis.FieldError { | ||
|
@@ -123,6 +128,17 @@ func (ds *DeliverySpec) Validate(ctx context.Context) *apis.FieldError { | |
} | ||
} | ||
|
||
if ds.Format != nil { | ||
validFormats := map[string]bool{ | ||
"structured": true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Cali0707 I was thinking now, since "structured" is not an event format but rather "JSON" is an event format, should we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a good point- let's use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will |
||
"binary": true, | ||
"ingress": true, | ||
} | ||
if !validFormats[*ds.Format] { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would do a case insensitive comparison There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This panics if
|
||
errs = errs.Also(apis.ErrInvalidValue(*ds.Format, "format")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would add the details of the error with the list of valid values (3rd parameter to ErrInvalidValue)
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the feedback! I will make the changes |
||
} | ||
} | ||
|
||
if ds.RetryAfterMax != nil { | ||
if feature.FromContext(ctx).IsEnabled(feature.DeliveryRetryAfter) { | ||
p, me := period.Parse(*ds.RetryAfterMax) | ||
|
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 would change the description here to be more specific
Something like