Skip to content
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

Merged
merged 4 commits into from
Jul 9, 2024
Merged

Conversation

EraKin575
Copy link
Contributor

@EraKin575 EraKin575 commented Jul 5, 2024

Fixes #8073
added format flag to deliverytype struct to support more destination of cloudevents

Proposed Changes

Pre-review Checklist

  • At least 80% unit test coverage
  • E2E tests for any new behavior
  • Docs PR for any user-facing impact
  • Spec PR for any new API feature
  • Conformance test for any change to the spec

Release Note


Docs

Signed-off-by: EraKin575 <[email protected]>
@knative-prow knative-prow bot requested review from aliok and lionelvillard July 5, 2024 05:55
@knative-prow knative-prow bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jul 5, 2024
Copy link

knative-prow bot commented Jul 5, 2024

Welcome @EraKin575! It looks like this is your first PR to knative/eventing 🎉

Copy link

knative-prow bot commented Jul 5, 2024

Hi @EraKin575. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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-sigs/prow repository.

@knative-prow knative-prow bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 5, 2024
Signed-off-by: EraKin575 <[email protected]>
Copy link
Member

@pierDipi pierDipi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @EraKin575, left a few comments

@@ -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)
Copy link
Member

@pierDipi pierDipi Jul 5, 2024

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

Format specifies the event format sent to subscriber and dead letter sink. 
Valid values are: 
- `json` <add link_to_cloudevents_spec_json_strucutred_format>
- `binary` <add link_to_cloudevents_spec binary format for HTTP>
- `ingress` <add description>

@@ -123,6 +128,17 @@ func (ds *DeliverySpec) Validate(ctx context.Context) *apis.FieldError {
}
}

if ds.Format != nil {
validFormats := map[string]bool{
"structured": true,
Copy link
Member

Choose a reason for hiding this comment

The 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 JSON, so that if we would need to support "XML" or "protobuf" we could?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point- let's use JSON instead then. @EraKin575 can you make the necessary changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will

"binary": true,
"ingress": true,
}
if !validFormats[*ds.Format] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would do a case insensitive comparison !validFormats[strings.ToLower(*ds.Format)]

"ingress": true,
}
if !validFormats[*ds.Format] {
errs = errs.Also(apis.ErrInvalidValue(*ds.Format, "format"))
Copy link
Member

@pierDipi pierDipi Jul 5, 2024

Choose a reason for hiding this comment

The 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)

apis.ErrInvalidValue(*ds.Format, "format", <detailed error>)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! I will make the changes

"binary": true,
"ingress": true,
}
if !validFormats[*ds.Format] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This panics if ds.Format is not in the map, we need to do something like

_, ok := validFormats[*ds.Format]; !ok {

}

Copy link
Member

@pierDipi pierDipi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a few test cases for the validation of Format in

func TestDeliverySpecValidation(t *testing.T) {

@Cali0707
Copy link
Member

Cali0707 commented Jul 5, 2024

@EraKin575 you will also need to run ./hack/update-codegen.sh and commit those changes, due to the API type change you made

Signed-off-by: EraKin575 <[email protected]>
@knative-prow knative-prow bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 5, 2024
@EraKin575 EraKin575 requested review from pierDipi and Cali0707 July 5, 2024 20:40
Signed-off-by: EraKin575 <[email protected]>
Copy link
Member

@Cali0707 Cali0707 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve
/ok-to-test

@knative-prow knative-prow bot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Jul 9, 2024
@knative-prow knative-prow bot added lgtm Indicates that a PR is ready to be merged. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 9, 2024
Copy link

knative-prow bot commented Jul 9, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Cali0707, EraKin575

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 9, 2024
@knative-prow knative-prow bot merged commit 9eed163 into knative:main Jul 9, 2024
7 checks passed
@EraKin575
Copy link
Contributor Author

merged my first PR at knative!

@EraKin575 EraKin575 deleted the delivery-format branch July 11, 2024 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Delivery Format: add the format field to the Delivery type
3 participants