Skip to content

Commit 0294e6b

Browse files
RealAnnaarttor
authored andcommitted
fix according to review
Signed-off-by: RealAnna <[email protected]>
1 parent f4ef62c commit 0294e6b

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

examples/operator/templates/deployment.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,7 @@ spec:
114114
name: manager-config
115115
- name: secret-volume
116116
secret:
117-
secretName: {{ include "operator.fullname" . }}-secret-ca
117+
secretName: {{ include "operator.fullname" . }}-secret-ca
118+
{{- if .Values.topologySpreadConstraints }}
119+
topologySpreadConstraints: {{- include "tplvalues.render" (dict "value" .Values.topologySpreadConstraints "context" $) | nindent 8 }}
120+
{{- end }}

pkg/processor/constraints/constraint.go

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ const tolerationsExpression = "{{- if .Values.tolerations }}\n" +
2525
// already has one defined.
2626
func ProcessSpecMap(name string, specMap map[string]interface{}, values *helmify.Values, defaultEmpty bool) string {
2727

28-
mapConstraint(name, specMap, topology, values)
29-
mapConstraint(name, specMap, tolerations, values)
30-
mapConstraint(name, specMap, nodeSelector, values)
3128
spec, err := yamlformat.Marshal(specMap, 6)
3229
if err != nil {
3330
return ""
@@ -40,18 +37,31 @@ func ProcessSpecMap(name string, specMap map[string]interface{}, values *helmify
4037
return spec + topologyExpression + nodeSelectorExpression + tolerationsExpression
4138
}
4239

43-
return spec
44-
}
40+
if specMap[topology] != nil {
41+
(*values)[name].(map[string]interface{})[topology] = specMap[topology].(interface{})
42+
delete(specMap, topology)
43+
spec += topologyExpression
44+
}
4545

46-
func mapConstraintWithEmpty(name string, specMap map[string]interface{}, constraint string, override interface{}, values *helmify.Values) {
47-
if specMap[constraint] == nil {
48-
(*values)[name].(map[string]interface{})[constraint] = override
46+
if specMap[tolerations] != nil {
47+
(*values)[name].(map[string]interface{})[tolerations] = specMap[tolerations].(interface{})
48+
delete(specMap, tolerations)
49+
spec += tolerationsExpression
4950
}
50-
delete(specMap, topology)
51+
if specMap[nodeSelector] != nil {
52+
(*values)[name].(map[string]interface{})[nodeSelector] = specMap[nodeSelector].(interface{})
53+
delete(specMap, nodeSelector)
54+
spec += nodeSelectorExpression
55+
}
56+
57+
return spec
5158
}
5259

53-
func mapConstraint(name string, specMap map[string]interface{}, constraint string, values *helmify.Values) {
60+
func mapConstraintWithEmpty(name string, specMap map[string]interface{}, constraint string, override interface{}, values *helmify.Values) {
5461
if specMap[constraint] != nil {
5562
(*values)[name].(map[string]interface{})[constraint] = specMap[constraint].(interface{})
63+
} else {
64+
(*values)[name].(map[string]interface{})[constraint] = override
5665
}
66+
delete(specMap, constraint)
5767
}

0 commit comments

Comments
 (0)