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: add variables field to the v1beta3 eventtype spec #8445

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Ahmed-Labs
Copy link
Contributor

@Ahmed-Labs Ahmed-Labs commented Feb 4, 2025

Fixes #7729

Proposed Changes

  • Add EventVariableDefinitions to EventTypeSpec
  • Validate whether variables used within attribute values are defined
  • Update EventType v1beta3 CRD with added variables field

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

Copy link

linux-foundation-easycla bot commented Feb 4, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@knative-prow knative-prow bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 4, 2025
Copy link

knative-prow bot commented Feb 4, 2025

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

Copy link

knative-prow bot commented Feb 4, 2025

Hi @Ahmed-Labs. 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 requested review from aslom and Cali0707 February 4, 2025 06:23
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.

Awesome start @Ahmed-Labs, thanks for working on this!

I left a few comments, and then I think this will be good to merge

@Cali0707
Copy link
Member

Cali0707 commented Feb 4, 2025

/ok-to-test

@knative-prow knative-prow bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 4, 2025
@Cali0707
Copy link
Member

Cali0707 commented Feb 4, 2025

/cc @pierDipi @matzew

FYI, this is the follow up regarding eventtypes with variables

@knative-prow knative-prow bot requested review from matzew and pierDipi February 4, 2025 15:08
Copy link

codecov bot commented Feb 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.16%. Comparing base (cdc6144) to head (71b4b68).
Report is 7 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8445      +/-   ##
==========================================
+ Coverage   64.10%   64.16%   +0.06%     
==========================================
  Files         388      388              
  Lines       23363    23405      +42     
==========================================
+ Hits        14976    15018      +42     
  Misses       7591     7591              
  Partials      796      796              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

knative-prow bot commented Feb 4, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Ahmed-Labs
Once this PR has been reviewed and has the lgtm label, please ask for approval from cali0707. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@Cali0707
Copy link
Member

Cali0707 commented Feb 6, 2025

/ok-to-test

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.

@Ahmed-Labs can you fix the format errors?

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

/cc @matzew @pierDipi

Could one of you provide a second review on this?

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Feb 11, 2025
Comment on lines +74 to +76
// Variables is an array that provides definitions for variables used within attribute values.
// +optional
Variables []EventVariableDefinition `json:"variables,omitempty"`
Copy link
Member

@pierDipi pierDipi Feb 25, 2025

Choose a reason for hiding this comment

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

We need to ensure that every EventType version can be converted to and from v1beta3, so we need to add these new fields (and type) to every other served version (v1beta2 and v1beta1), otherwise the new fields will be dropped as the objects are stored using v1beta2:

- name: v1beta2
served: true
storage: true

Also we would need to update the validation functions for other versions too as it's done in the PR for v1beta3, so perhaps, we can extract common logic (like extract variables, etc) to a common file like ./pkg/apis/eventing/eventtype_validation_common.go


Once we've added the fields, types and validations to other versions, we need to update the conversion functions (for v1beta1 and v1beta2) like this one to set such new fields

https://github.com/knative/eventing/blob/71b4b68d3fd2e06d587fb05887027b3e6e15eb35/pkg/apis/eventing/v1beta1/eventtype_conversion.go

Comment on lines +153 to +155
}, {
name: "invalid eventtype due to missing variable definitions",
ets: &EventTypeSpec{
Copy link
Member

Choose a reason for hiding this comment

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

Would this be a valid and interesting case to test as well? test.{test\\{Variable}.{defined\\}Variable}

@pierDipi
Copy link
Member

Thanks @Ahmed-Labs, I left a review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Event Discovery: Add Variables to EventType V1Beta3 spec
3 participants