From f2f76bc194e35f14d4703a3068e6bc02809a3897 Mon Sep 17 00:00:00 2001 From: Tibi <110664232+TiberiuGC@users.noreply.github.com> Date: Tue, 13 Aug 2024 09:24:27 +0300 Subject: [PATCH] Fix logic that allows ignoring Resource and SDK setters (#539) Issue #, if available: Description of changes: - fix logic that allows ignoring SDK setters (i.e. `sdkCreate` and `sdkUpdate`) for nested fields. The field path map is currently queried using a wrong key i.e. the field name instead of field path. - introduce logic that allows ignoring Resource setters (i.e. `sdkFind`). By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. --- pkg/generate/code/set_resource.go | 14 ++++++++++++++ pkg/generate/code/set_sdk.go | 3 +-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pkg/generate/code/set_resource.go b/pkg/generate/code/set_resource.go index e771abb3..b5156abd 100644 --- a/pkg/generate/code/set_resource.go +++ b/pkg/generate/code/set_resource.go @@ -1301,6 +1301,20 @@ func SetResourceForStruct( var sourceAdaptedVarName, qualifiedTargetVar string for _, targetMemberName := range targetShape.MemberNames() { + // To check if the field member has `ignore` set to `true`. + // This condition currently applies only for members of a field whose shape is `structure`. + var setCfg *ackgenconfig.SetFieldConfig + f, ok := r.Fields[targetFieldPath] + if ok { + mf, ok := f.MemberFields[targetMemberName] + if ok { + setCfg = mf.GetSetterConfig(op) + if setCfg != nil && setCfg.IgnoreResourceSetter() { + continue + } + } + } + sourceMemberShapeRef = sourceShape.MemberRefs[targetMemberName] if sourceMemberShapeRef == nil { continue diff --git a/pkg/generate/code/set_sdk.go b/pkg/generate/code/set_sdk.go index 75c914a1..c5362d8a 100644 --- a/pkg/generate/code/set_sdk.go +++ b/pkg/generate/code/set_sdk.go @@ -1108,7 +1108,7 @@ func SetSDKForStruct( // To check if the field member has `ignore` set to `true`. // This condition currently applies only for members of a field whose shape is `structure` var setCfg *ackgenconfig.SetFieldConfig - f, ok := r.Fields[targetFieldName] + f, ok := r.Fields[sourceFieldPath] if ok { mf, ok := f.MemberFields[memberName] if ok { @@ -1117,7 +1117,6 @@ func SetSDKForStruct( continue } } - } fallBackName := r.GetMatchingInputShapeFieldName(op, targetFieldName)