Skip to content

Commit 4fadf0b

Browse files
committed
adding support for map[string]bool types (aws-controllers-k8s#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 4fadf0b

File tree

5 files changed

+44
-6
lines changed

5 files changed

+44
-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+
}

Diff for: templates/cmd/controller/main.go.tpl

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package main
55
import (
66
"os"
77
"context"
8+
"strings"
89

910
ackv1alpha1 "github.com/aws-controllers-k8s/runtime/apis/core/v1alpha1"
1011
ackcfg "github.com/aws-controllers-k8s/runtime/pkg/config"

Diff for: templates/helm/templates/deployment.yaml.tpl

+4
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ spec:
5959
- "$(ACK_WATCH_NAMESPACE)"
6060
- --watch-selectors
6161
- "$(ACK_WATCH_SELECTORS)"
62+
- --reconcile-resources
63+
- "$(RECONCILE_RESOURCES)"
6264
- --deletion-policy
6365
- "$(DELETION_POLICY)"
6466
{{ "{{- if .Values.leaderElection.enabled }}" }}
@@ -107,6 +109,8 @@ spec:
107109
value: {{ IncludeTemplate "watch-namespace" }}
108110
- name: ACK_WATCH_SELECTORS
109111
value: {{ "{{ .Values.watchSelectors }}" }}
112+
- name: RECONCILE_RESOURCES
113+
value: {{ "{{ .Values.reconcileResources }}" }}
110114
- name: DELETION_POLICY
111115
value: {{ "{{ .Values.deletionPolicy }}" }}
112116
- name: LEADER_ELECTION_NAMESPACE

Diff for: templates/helm/values.schema.json

+3
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@
214214
"watchSelectors": {
215215
"type": "string"
216216
},
217+
"reconcileResources": {
218+
"type": "string"
219+
},
217220
"resourceTags": {
218221
"type": "array",
219222
"items": {

Diff for: templates/helm/values.yaml.tpl

+5
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ watchNamespace: ""
114114
# You can set multiple labelsSelectors by providing a comma separated list of a=b arguments. e.g "label1=value1,label2=value2"
115115
watchSelectors: ""
116116

117+
# Set the value of reconcileResources to specify which resource kinds to reconcile.
118+
# You can set multiple resource kinds by providing a comma separated list. e.g "Kind1,Kind2"
119+
# If unspecified, all resources will be reconciled.
120+
reconcileResources: ""
121+
117122
resourceTags:
118123
# Configures the ACK service controller to always set key/value pairs tags on
119124
# resources that it manages.

0 commit comments

Comments
 (0)