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 support for empty shapes, used as booleans in SDK #536

Merged
merged 1 commit into from
Aug 14, 2024

Conversation

TiberiuGC
Copy link
Member

@TiberiuGC TiberiuGC commented Aug 8, 2024

Issue #, if available: prerequisite for WAFv2 RuleGroup and WebACL CRDs

Description of changes:

Some WAFv2 API fields have empty json specs {}, e.g. https://docs.aws.amazon.com/waf/latest/APIReference/API_AllQueryArguments.html

For these type of fields, codegen currently errors out because it infers their gotypes as e.g.
AllQueryArguments *AllQueryArguments

but does not generate a type AllQueryArguments struct since the struct itself is empty, and not picked up by newFieldRecurse function.

The solution proposed in this PR is to allow users to define marker-shapes, which instruct codegen to overwrite the type of these empty structs as []byte, both when generating the APIs and when setting up the SDK.

e.g. generator.yaml for WAFv2, and inline:

empty_shapes:
- All
- Method
- UriPath
- QueryString
- AllQueryArguments
- RateLimitIP
- RateLimitForwardedIP
- RateLimitHTTPMethod
- NoneAction

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ack-prow ack-prow bot requested review from a-hilaly and jlbutler August 8, 2024 11:34
@TiberiuGC TiberiuGC force-pushed the feature/marker-shapes branch from a9705b8 to 34e3d4b Compare August 8, 2024 11:39
@a-hilaly
Copy link
Member

a-hilaly commented Aug 8, 2024

@TiberiuGC this is great, i love it! Can you please provide an example generator.yaml in the PR description?

@TiberiuGC TiberiuGC force-pushed the feature/marker-shapes branch from 34e3d4b to ec4cbc2 Compare August 8, 2024 21:24
@TiberiuGC
Copy link
Member Author

/retest

@TiberiuGC TiberiuGC force-pushed the feature/marker-shapes branch from c00c657 to c3a897b Compare August 9, 2024 13:11
@TiberiuGC
Copy link
Member Author

/retest

2 similar comments
@TiberiuGC
Copy link
Member Author

/retest

@a-hilaly
Copy link
Member

/retest

@TiberiuGC TiberiuGC force-pushed the feature/marker-shapes branch from c3a897b to 3050ec1 Compare August 13, 2024 16:41
@TiberiuGC TiberiuGC changed the title Add support for empty shapes, used as markers Add support for empty shapes, used as booleans in SDK Aug 13, 2024
Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

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

Thank you @TiberiuGC , you rock!
/lgtm

@ack-prow ack-prow bot added the lgtm Indicates that a PR is ready to be merged. label Aug 14, 2024
Copy link

ack-prow bot commented Aug 14, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: a-hilaly, TiberiuGC

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

@ack-prow ack-prow bot added the approved label Aug 14, 2024
@a-hilaly
Copy link
Member

/retest

@ack-prow ack-prow bot merged commit bdf3f26 into aws-controllers-k8s:main Aug 14, 2024
17 of 18 checks passed
ack-prow bot pushed a commit that referenced this pull request Aug 16, 2024
Issue #, if available:

Description of changes:
New unit tests cover code-gen bugfixes and improvements, pre-requisites for WAFv2 controller:
- #539
- #538
- #536

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants