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

Add specification packages #78

Merged
merged 8 commits into from
May 17, 2024
Merged

Conversation

afrittoli
Copy link
Contributor

Add a go package that holds an unversioned alias of the API for creating events. This let user import the versioned package and have access to a simpler API which picks the right version of each event based on the spec version.

There is still work to be done to support multiple versions, as the context may vary across versions, which is not yet handled.

Copy link

codecov bot commented May 2, 2024

Codecov Report

Attention: Patch coverage is 85.09174% with 65 lines in your changes are missing coverage. Please review.

Project coverage is 79.94%. Comparing base (7eb4b5a) to head (0029e15).

Files Patch % Lines
tools/generator.go 0.00% 49 Missing ⚠️
pkg/api/v990/types.go 33.33% 6 Missing ⚠️
pkg/api/types.go 71.42% 3 Missing and 1 partial ⚠️
pkg/api/v03/docs.go 97.56% 2 Missing ⚠️
pkg/api/v990/docs.go 66.66% 2 Missing ⚠️
pkg/api/zz_ztest_foosubjectbarpredicate_1_2_3.go 93.10% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #78      +/-   ##
==========================================
- Coverage   80.05%   79.94%   -0.12%     
==========================================
  Files          46       48       +2     
  Lines        3164     3291     +127     
==========================================
+ Hits         2533     2631      +98     
- Misses        524      552      +28     
- Partials      107      108       +1     

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

@afrittoli afrittoli force-pushed the spec_packages branch 6 times, most recently from 59b4477 to ef7a8ca Compare May 8, 2024 12:35
Add a go package that holds an unversioned alias of the API for
creating events. This let user import the versioned package and
have access to a simpler API which picks the right version of
each event based on the spec version.

There is still work to be done to support multiple versions, as
the context may vary across versions, which is not yet handled.

Signed-off-by: Andrea Frittoli <[email protected]>
Add the spec version to the event contructors.
Use the constructors aliases in docs.go to pass the correct version of
the spec directly.

Extend the parsing API with generics, so that it may take the type of
context as input. For now, the only type available is Context, but
once we do breaking changes to the spec, there will be more than one
version of Context, and the parsing method will need to take a version
specific context type.

Change the context.type from String to CDEventsType and define custom
JSON marshaller and unmarshaller to keep the error handling logic in
the correct place in the code and simplify the code in general.

Signed-off-by: Andrea Frittoli <[email protected]>
Make the test events part of a test spec version.
Move parsing functions to spec specific packages where needed.

Signed-off-by: Andrea Frittoli <[email protected]>
Signed-off-by: Andrea Frittoli <[email protected]>
Use a bit of template logic to reduce the number of templates.
Add no-build tags to the test SDK files.

Signed-off-by: Andrea Frittoli <[email protected]>
@afrittoli afrittoli added this pull request to the merge queue May 17, 2024
Merged via the queue into cdevents:main with commit f8b8b91 May 17, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: No status
Development

Successfully merging this pull request may close these issues.

1 participant