Skip to content

Commit a782a62

Browse files
authored
adding support for map[string]bool types (#579)
Description of changes: **Needs rebase to the removed shamelist** adding support `map[string]bool` types By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent ec13658 commit a782a62

File tree

1 file changed

+31
-6
lines changed

1 file changed

+31
-6
lines changed

Diff for: pkg/generate/code/set_sdk.go

+31-6
Original file line numberDiff line numberDiff line change
@@ -1374,7 +1374,7 @@ func setSDKForMap(
13741374
out += fmt.Sprintf("%s}\n", indent)
13751375
return out
13761376
} else if targetShape.ValueRef.Shape.ValueRef.Shape.Type == "boolean" {
1377-
out += fmt.Sprintf("%s\t%s[%s] = aws.ToBoolgMap(%s)\n", indent, targetVarName, keyVarName, valIterVarName)
1377+
out += fmt.Sprintf("%s\t%s[%s] = aws.ToBoolMap(%s)\n", indent, targetVarName, keyVarName, valIterVarName)
13781378
out += fmt.Sprintf("%s}\n", indent)
13791379
return out
13801380
}
@@ -1636,15 +1636,40 @@ 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" &&
1639+
} else if shape.Type == "map" &&
16401640
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)
1641+
isPrimitiveType(shape.ValueRef.Shape.Type) {
1642+
mapType := resolveAWSMapValueType(shape.ValueRef.Shape.Type)
1643+
out += fmt.Sprintf("%s\t%s.%s = aws.To%sMap(%s)\n", indent, targetVarName, memberName, mapType, sourceAdaptedVarName)
16431644
}
1644-
16451645
return out
16461646
}
16471647

1648+
func isPrimitiveType(valueType string) bool {
1649+
switch valueType {
1650+
case "string", "boolean", "integer", "long", "float", "double":
1651+
return true
1652+
default:
1653+
return false
1654+
}
1655+
}
1656+
1657+
func resolveAWSMapValueType(valueType string) string {
1658+
switch valueType {
1659+
case "string":
1660+
return "String"
1661+
case "boolean":
1662+
return "Bool"
1663+
case "integer", "long":
1664+
return "Int64"
1665+
case "float", "double":
1666+
return "Float64"
1667+
default:
1668+
// For any other type, return String as a safe fallback
1669+
return "String"
1670+
}
1671+
}
1672+
16481673
func setSDKForUnion(
16491674
cfg *ackgenconfig.Config,
16501675
r *model.CRD,
@@ -1749,4 +1774,4 @@ func setSDKForUnion(
17491774
}
17501775

17511776
return out
1752-
}
1777+
}

0 commit comments

Comments
 (0)