Commit c7b19a3
authored
collect Field structs for members of structures (#258)
When inferring the structure of a CRD and its fields, we create a
`pkg/model.Field` struct for each *top-level* field in the CRD's Spec or
Status. The `pkg/model.GetCRDs()` function ends up calling
`pkg/model.CRD:AddSpecField()` and `pkg/model.CRD:AddStatusField()` for
those field definitions that the API inference stage of the generation
pipeline discovers in the aws-sdk-go API model.
Because we were creating `pkg/model.Field` objects for only the
top-level fields in Spec and Status and the `pkg/model.Field` object is
what was tied to a `pkg/generate/config.FieldConfig` object, this meant
that only the top-level field definitions were able to be *configured*
via the generator.yaml file. This is a problem for more complex APIs
like EC2 which have resources with top-level fields that are structures
themselves. We were not able to configure nested fields properly because
we were not actually constructing a `pkg/model.Field` object for these
nested fields.
This PR enhances the API inference process inside the code generator to
detect when a new `pkg/model.Field` refers to an
`aws-sdk-go/private/model.Shape` that is of type "structure" and recurse
through that Shape's MemberRefs collection, building a map of
`pkg/model.Field` objects for each member field along with a fieldpath
that allows these nested struct member fields to later be "found" by the
code generator.
Issue: aws-controllers-k8s/community#1100
Signed-off-by: Jay Pipes <jaypipes@gmail.com>
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.1 parent 3e18472 commit c7b19a3
2 files changed
+56
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
50 | 54 | | |
51 | 55 | | |
52 | 56 | | |
| |||
162 | 166 | | |
163 | 167 | | |
164 | 168 | | |
| 169 | + | |
165 | 170 | | |
166 | 171 | | |
167 | 172 | | |
| |||
170 | 175 | | |
171 | 176 | | |
172 | 177 | | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
173 | 187 | | |
174 | 188 | | |
175 | 189 | | |
| |||
184 | 198 | | |
185 | 199 | | |
186 | 200 | | |
| 201 | + | |
187 | 202 | | |
188 | 203 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
0 commit comments