-
Notifications
You must be signed in to change notification settings - Fork 267
SetFieldConfig
is not being consumed for nested Resource fields
#1146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
area/code-generation
Issues or PRs as related to controllers or docs code generation
kind/bug
Categorizes issue or PR as related to a bug.
Comments
Some Root Causes
|
ack-bot
pushed a commit
to aws-controllers-k8s/code-generator
that referenced
this issue
Feb 11, 2022
…#289) Issue #, if available: aws-controllers-k8s/community#1146 After a recent update to `/pkg/model/field.go`, shapes _may_ contain **additional** fields/members with a "nested" format such as **DHCPOptions.Fields**: `[DHCPConfigurations TagSpecifications.Tags.Value Tags.Value TagSpecifications DHCPConfigurations.Values TagSpecifications.ResourceType TagSpecifications.Tags Tags.Key DHCPOptionsID OwnerID DHCPConfigurations.Key TagSpecifications.Tags.Key DryRun Tags]` The purpose of that update is to allow users to easily fetch nested shapes and their corresponding configurations using the "nested" field name as the key. However, `SetResourceForStruct` will never have the opportunity to process and/or fetch shapes and configs for these "nested" fields because the algorithm processes fields **iff they exist in sourceShape**. *Note, sourceShape comes directly from `aws-sdk` in this context, so will NOT have these additional, nested fields.* This patch iterates over `targetShape.Members` instead of `sourceShape` so these "nested" fields can be included in the lookup logic, but continues to use `sourceShape` index for consistency throughout codebase. There's no change in functionality, but this paves the way for a follow-up PR to check a targetShape's nested Field `SetConfig` if the Field cannot be found in the sourceShape: ``` sourceMemberShapeRef := sourceShape.MemberRefs[targetMemberName] if sourceMemberShapeRef == nil { continue } // Future patch: check if targetMemberName has SetConfig logic that needs to be processed ``` By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
ack-bot
pushed a commit
to aws-controllers-k8s/code-generator
that referenced
this issue
Feb 17, 2022
…mbers (#292) Issue #, if available: aws-controllers-k8s/community#1146 This is a follow-up to #289. A `targetShape` without members in `SetResourceForStruct` will not be processed today; however, this is **not** desired behavior for all APIs such as EC2's DHCPOptions resource. This patch will look up and consume `SetConfig` in `SetResourceForStruct` when `targetShape` has no members like when DHCPOptions' field, `DHCPConfigurations.Values []*string`, aligns (by name) with aws-sdk's output shape, `DhcpConfigurations.Values []*AttributeValue`. Instead of skipping the processing of `Values []*string` field, it will check if a `SetConfig` exists and if it's valid (referencing a *real* shape in sourceShape), then use that updated field to source the target field's value resulting in using `DhcpConfigurations.Values.Value *string` to populate the resource's `DHCPConfigurations.Values []*string`. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area/code-generation
Issues or PRs as related to controllers or docs code generation
kind/bug
Categorizes issue or PR as related to a bug.
Describe the bug
SetFieldConfig
for nested Resource fieldsSteps to reproduce
SetFieldConfig
toec2-controller/generator.yaml
to properly generate DhcpOptions:export SERVICE=ec2 && make build-controller
Actual outcome
sdkFind/sdkCreate
:f0elemf1iter
is unused andf0elemf1elem
is never assigned.Expected outcome
SetFieldConfig
to generate DhcpOptions Controller code correctly:Environment
The text was updated successfully, but these errors were encountered: