You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue #, if available: aws-controllers-k8s/community#1212
This PR aims to add support for adding ResourceReferences for nested fields. I have tested these changes locally by generating and compiling *eks-controller* and *apigatewayv2-controller*, and also added unit tests.
In a nut-shell, this PR mainly updates the reference resolution to use `field.Path` instead of `field.Names` with proper nil checks. This PR also updates the TypeDefs to add new *AWSResourceReference* attribute, instead of only supporting Reference fields at top-level. More detailed desciption about the changes is present below.
Note: I have broken all the changes into multiple commits and i recommend to review this PR commit-by-commit. : )
Description of changes:
* Add new reusable go code generator method for producing Nil check logical condition on a *fieldPath*
* Wrap the *ReferenceFieldValidation* with proper Nil check for a fieldPath and correctly use *field.Path* for accessing the value instead of `field.Names.Camel`
* Include Nil checks inside `ReferenceFieldPresent` method for the `field.Path` and capture the ReferenceFieldPresent condition for each field inside parentheses to make it more readable.
* Make the ResourceFieldConfig lookup case-insensitive for better developer experience . This will allow developers to not worry about case-sensitivity when creating FieldConfig keys inside `generator.yaml`
* Update `crd.HasReference` method to work for nested fields as well.
* Update *TypeDef* generation inside `model.go` to also include new *AWSResourceReference* attribute if a nested field *ReferencesConfig* is present.
* Update `references.go.tpl` to correctly use *field.Path* instead of *field.Names* to resolve references.
* Update `references.go.tpl` to support string type-alias by performing type-casting before resolving a reference.(issue# aws-controllers-k8s/community#1213)
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
0 commit comments