Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for empty shapes, used as booleans in SDK (#536)
Issue #, if available: prerequisite for WAFv2 [RuleGroup](aws-controllers-k8s/wafv2-controller#6) and [WebACL](aws-controllers-k8s/wafv2-controller#7) 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](https://github.com/aws-controllers-k8s/wafv2-controller/blob/bb682409da8f96c5035783602b9d948c8cc8e21f/apis/v1alpha1/generator.yaml#L15-L24) 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.
- Loading branch information