Commit bdf3f26
authored
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.1 parent 8b54e42 commit bdf3f26
3 files changed
+26
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
151 | 153 | | |
152 | 154 | | |
153 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
154 | 167 | | |
155 | 168 | | |
156 | 169 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1387 | 1387 | | |
1388 | 1388 | | |
1389 | 1389 | | |
1390 | | - | |
1391 | | - | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
1392 | 1397 | | |
1393 | 1398 | | |
1394 | 1399 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
471 | 471 | | |
472 | 472 | | |
473 | 473 | | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
474 | 480 | | |
475 | 481 | | |
476 | 482 | | |
| |||
0 commit comments