Skip to content

adding support for map[string]bool types #579

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

Merged
merged 2 commits into from
Apr 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 0 additions & 146 deletions pkg/api/list_of_shame.go
Original file line number Diff line number Diff line change
@@ -29,152 +29,6 @@ func (ts persistAPITypes) Output(serviceName, opName string) bool {
// not generating unique input/output shapes is not desired, we will generate
// unique input/output shapes for new operations.
var shamelist = persistAPITypes{
"APIGateway": {
"CreateApiKey": {
output: true,
},
"CreateAuthorizer": {
output: true,
},
"CreateBasePathMapping": {
output: true,
},
"CreateDeployment": {
output: true,
},
"CreateDocumentationPart": {
output: true,
},
"CreateDocumentationVersion": {
output: true,
},
"CreateDomainName": {
output: true,
},
"CreateModel": {
output: true,
},
"CreateUsagePlan": {
output: true,
},
"CreateUsagePlanKey": {
output: true,
},
"GenerateClientCertificate": {
output: true,
},
"GetAccount": {
output: true,
},
"GetApiKey": {
output: true,
},
"GetAuthorizer": {
output: true,
},
"GetBasePathMapping": {
output: true,
},
"GetClientCertificate": {
output: true,
},
"GetDeployment": {
output: true,
},
"GetDocumentationPart": {
output: true,
},
"GetDocumentationVersion": {
output: true,
},
"GetDomainName": {
output: true,
},
"GetIntegrationResponse": {
output: true,
},
"GetMethod": {
output: true,
},
"GetMethodResponse": {
output: true,
},
"GetModel": {
output: true,
},
"GetSdkType": {
output: true,
},
"GetUsage": {
output: true,
},
"GetUsagePlan": {
output: true,
},
"GetUsagePlanKey": {
output: true,
},
"ImportRestApi": {
output: true,
},
"PutIntegrationResponse": {
output: true,
},
"PutMethod": {
output: true,
},
"PutMethodResponse": {
output: true,
},
"PutRestApi": {
output: true,
},
"UpdateAccount": {
output: true,
},
"UpdateApiKey": {
output: true,
},
"UpdateAuthorizer": {
output: true,
},
"UpdateBasePathMapping": {
output: true,
},
"UpdateClientCertificate": {
output: true,
},
"UpdateDeployment": {
output: true,
},
"UpdateDocumentationPart": {
output: true,
},
"UpdateDocumentationVersion": {
output: true,
},
"UpdateDomainName": {
output: true,
},
"UpdateIntegrationResponse": {
output: true,
},
"UpdateMethod": {
output: true,
},
"UpdateMethodResponse": {
output: true,
},
"UpdateModel": {
output: true,
},
"UpdateUsage": {
output: true,
},
"UpdateUsagePlan": {
output: true,
},
},
"AutoScaling": {
"ResumeProcesses": {
input: true,
37 changes: 31 additions & 6 deletions pkg/generate/code/set_sdk.go
Original file line number Diff line number Diff line change
@@ -1374,7 +1374,7 @@ func setSDKForMap(
out += fmt.Sprintf("%s}\n", indent)
return out
} else if targetShape.ValueRef.Shape.ValueRef.Shape.Type == "boolean" {
out += fmt.Sprintf("%s\t%s[%s] = aws.ToBoolgMap(%s)\n", indent, targetVarName, keyVarName, valIterVarName)
out += fmt.Sprintf("%s\t%s[%s] = aws.ToBoolMap(%s)\n", indent, targetVarName, keyVarName, valIterVarName)
out += fmt.Sprintf("%s}\n", indent)
return out
}
@@ -1636,15 +1636,40 @@ func setSDKAdaptiveResourceCollection(
out += fmt.Sprintf("%s\t%s.%s = aws.ToInt64Slice(%s)\n", indent, targetVarName, memberName, sourceAdaptedVarName)

}
} else if shape.Type == "map" &&
} else if shape.Type == "map" &&
shape.KeyRef.Shape.Type == "string" &&
shape.ValueRef.Shape.Type == "string" {
out += fmt.Sprintf("%s\t%s.%s = aws.ToStringMap(%s)\n", indent, targetVarName, memberName, sourceAdaptedVarName)
isPrimitiveType(shape.ValueRef.Shape.Type) {
mapType := resolveAWSMapValueType(shape.ValueRef.Shape.Type)
out += fmt.Sprintf("%s\t%s.%s = aws.To%sMap(%s)\n", indent, targetVarName, memberName, mapType, sourceAdaptedVarName)
}

return out
}

func isPrimitiveType(valueType string) bool {
switch valueType {
case "string", "boolean", "integer", "long", "float", "double":
return true
default:
return false
}
}

func resolveAWSMapValueType(valueType string) string {
switch valueType {
case "string":
return "String"
case "boolean":
return "Bool"
case "integer", "long":
return "Int64"
case "float", "double":
return "Float64"
default:
// For any other type, return String as a safe fallback
return "String"
}
}

func setSDKForUnion(
cfg *ackgenconfig.Config,
r *model.CRD,
@@ -1749,4 +1774,4 @@ func setSDKForUnion(
}

return out
}
}