fix: resolve Go field names correctly in late_initialize code generation#708
fix: resolve Go field names correctly in late_initialize code generation#708michaelhtm wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: michaelhtm The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
generated aws-controllers-k8s/sqs-controller#107 with these changes |
knottnt
left a comment
There was a problem hiding this comment.
Left a comment to see if we can use a shared utility for determining the Go field name that should be used. I'd guess we already have one that is being used elsewhere.
| // fieldGoName resolves a config field name to its Go-exported name using the | ||
| // CRD's field model. For attribute-unpacked fields, the config key may differ | ||
| // from the Go name (e.g. "SqsManagedSseEnabled" -> "SQSManagedSSEEnabled"). | ||
| func fieldGoName(r *model.CRD, configName string) string { |
There was a problem hiding this comment.
Q: It seems like this should be a problem we've already solved for the sdk.go code. How are we determining the Go field name there and can we re-use it here? Ideally, we should have one way of doing this that is shared by all of our generation functions.
There was a problem hiding this comment.
There isn't a standalone shared utility for this today.. sdk.go does it inline since it already has the field from iterating operation shapes. late_initialize is the only codepath starting from bare config keys.
Modified the function to lookup the existing field, instead of re-initializing names.New()
|
/retest |
fca4ec0 to
227fba8
Compare
The late_initialize template was using config field keys directly as Go
struct accessors. For fields from unpack_attributes_map (e.g. SQS
"SqsManagedSseEnabled"), the config key differs from the Go field name
("SQSManagedSSEEnabled"). This caused compilation errors in generated
controllers.
Resolves aws-controllers-k8s/community#2695
227fba8 to
ffbd449
Compare
|
/retest |
Description of changes:
The late_initialize template was using config field keys directly as Go
struct accessors. For fields from unpack_attributes_map (e.g. SQS
"SqsManagedSseEnabled"), the config key differs from the Go field name
("SQSManagedSSEEnabled"). This caused compilation errors in generated
controllers.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.