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
allow SetFieldConfig.From to refer to nested fields (#255)
Often, the Go type of a Create Input shape field (which goes in the
resource's Spec struct) is different from the Go type of the same-named
field in an Output shape. This causes problems for the code generator,
which doesn't know how to set the value of the Spec field due to these
different source and target Go types.
The `pkg/generate/config.SetConfig` struct was designed to solve this
particular issue, however the original solution only worked properly
when the field in the Output shape that we wanted to set the Spec field
*from* was at the same "level" as the field we wanted to set the value
*to*.
Take for example the case of the IAM Role resource, which has a Create
Input shape with a string `PermissionsBoundary` field. When creating the
Role, the user specifies the PermissionsBoundary as an ARN field. In the
Create and Get Output shapes, however, the `PermissionsBoundary` field
is a struct containing a `PermissionsBoundaryArn` string field. We want
to set the value of the Role resource's `Spec.PermissionsBoundary` field
to the string value of this nested
`PermissionsBoundary.PermissionsBoundaryArn` field. This patch
facilitates that by modifying the `pkg/generate/code.SetResource`
function to look up the field in the Output shape via a field path
instead of a single field name map lookup.
Issue aws-controllers-k8s/community#1065
Signed-off-by: Jay Pipes <[email protected]>
By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
0 commit comments