Skip to content

Commit bf1bf42

Browse files
committed
fix types for maps value types
1 parent cccb180 commit bf1bf42

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

pkg/generate/code/set_sdk.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,15 +1636,27 @@ func setSDKAdaptiveResourceCollection(
16361636
out += fmt.Sprintf("%s\t%s.%s = aws.ToInt64Slice(%s)\n", indent, targetVarName, memberName, sourceAdaptedVarName)
16371637

16381638
}
1639-
} else if shape.Type == "map" &&
1640-
shape.KeyRef.Shape.Type == "string" &&
1641-
shape.ValueRef.Shape.Type == "string" {
1642-
out += fmt.Sprintf("%s\t%s.%s = aws.ToStringMap(%s)\n", indent, targetVarName, memberName, sourceAdaptedVarName)
1639+
} else if shape.Type == "map" &&
1640+
shape.KeyRef.Shape.Type == "string" {
1641+
mapType := getAWSMapType(shape.ValueRef.Shape.Type)
1642+
out += fmt.Sprintf("%s\t%s.%s = aws.To%sMap(%s)\n", indent, targetVarName, memberName, mapType, sourceAdaptedVarName)
16431643
}
1644-
16451644
return out
16461645
}
16471646

1647+
func getAWSMapType(valueType string) string {
1648+
switch valueType {
1649+
case "string":
1650+
return "String"
1651+
case "boolean":
1652+
return "Bool"
1653+
default:
1654+
// For any other type, return String as a safe fallback
1655+
// This avoids generating undefined function calls
1656+
return "String"
1657+
}
1658+
}
1659+
16481660
func setSDKForUnion(
16491661
cfg *ackgenconfig.Config,
16501662
r *model.CRD,

0 commit comments

Comments
 (0)