Skip to content

Commit f2f76bc

Browse files
authored
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.
1 parent 83fa6d6 commit f2f76bc

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

pkg/generate/code/set_resource.go

+14
Original file line numberDiff line numberDiff line change
@@ -1301,6 +1301,20 @@ func SetResourceForStruct(
13011301
var sourceAdaptedVarName, qualifiedTargetVar string
13021302

13031303
for _, targetMemberName := range targetShape.MemberNames() {
1304+
// To check if the field member has `ignore` set to `true`.
1305+
// This condition currently applies only for members of a field whose shape is `structure`.
1306+
var setCfg *ackgenconfig.SetFieldConfig
1307+
f, ok := r.Fields[targetFieldPath]
1308+
if ok {
1309+
mf, ok := f.MemberFields[targetMemberName]
1310+
if ok {
1311+
setCfg = mf.GetSetterConfig(op)
1312+
if setCfg != nil && setCfg.IgnoreResourceSetter() {
1313+
continue
1314+
}
1315+
}
1316+
}
1317+
13041318
sourceMemberShapeRef = sourceShape.MemberRefs[targetMemberName]
13051319
if sourceMemberShapeRef == nil {
13061320
continue

pkg/generate/code/set_sdk.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ func SetSDKForStruct(
11081108
// To check if the field member has `ignore` set to `true`.
11091109
// This condition currently applies only for members of a field whose shape is `structure`
11101110
var setCfg *ackgenconfig.SetFieldConfig
1111-
f, ok := r.Fields[targetFieldName]
1111+
f, ok := r.Fields[sourceFieldPath]
11121112
if ok {
11131113
mf, ok := f.MemberFields[memberName]
11141114
if ok {
@@ -1117,7 +1117,6 @@ func SetSDKForStruct(
11171117
continue
11181118
}
11191119
}
1120-
11211120
}
11221121

11231122
fallBackName := r.GetMatchingInputShapeFieldName(op, targetFieldName)

0 commit comments

Comments
 (0)