Skip to content

Commit f712dd5

Browse files
committed
simplify nodeSelector config
1 parent 6893c66 commit f712dd5

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

helm/kaap/templates/operator.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,10 @@ spec:
4848
{{- include "kaap.selectorLabels" . | nindent 8 }}
4949
namespace: {{ .Release.Namespace }}
5050
spec:
51-
{{- if and (.Values.nodeSelector) (not .Values.operator.nodeSelector) }}
51+
{{- $nodeSelector := coalesce .Values.operator.nodeSelector .Values.nodeSelector -}}
52+
{{- if $nodeSelector }}
5253
nodeSelector:
53-
{{ toYaml .Values.nodeSelector | indent 8 }}
54-
{{- end }}
55-
{{- if .Values.operator.nodeSelector }}
56-
nodeSelector:
57-
{{ toYaml .Values.operator.nodeSelector | indent 8 }}
54+
{{ toYaml $nodeSelector | indent 8 }}
5855
{{- end }}
5956
{{- if .Values.operator.tolerations }}
6057
tolerations:

tests/src/test/java/com/datastax/oss/kaap/tests/BaseK8sEnvTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,7 @@ private String simulateHelmRendering(List<String> allRbac) {
237237
vars.put(".Values.operator.readinessProbe.periodSeconds", "30");
238238
vars.put(".Values.operator.readinessProbe.successThreshold", "1");
239239
vars.put(".Values.operator.readinessProbe.timeoutSeconds", "10");
240-
vars.put(".Values.nodeSelector", " {}");
241-
vars.put(".Values.operator.nodeSelector", " {}");
240+
vars.put("$nodeSelector", " {}");
242241
vars.put(".Values.operator.tolerations", " []");
243242
vars.put("include \"kaap.name\" .", "kaap");
244243
vars.put("include \"kaap.roleName\" .", "kaap");
@@ -249,9 +248,9 @@ private String simulateHelmRendering(List<String> allRbac) {
249248
vars.put("include \"kaap.selectorLabels\" . | nindent 8", "{app.kubernetes.io/name: kaap}");
250249
vars.put("include (print $.Template.BasePath \"/configmap.yaml\") . | sha256sum", "sha");
251250
String result = "";
252-
// simulate go templating
251+
// simulate Helm templating
253252
for (String l : allRbac) {
254-
if (l.contains("nodeSelector") || l.contains(".nodeSelector")) { // nodeselector is empty anyway. This resolves duplicate nodeselectors
253+
if (l.contains("{{- $")) { // ignore variable definitions
255254
continue;
256255
}
257256
if (l.contains("{{- if")) { // assume always true and no content other than the if
@@ -268,7 +267,7 @@ private String simulateHelmRendering(List<String> allRbac) {
268267
result += l + System.lineSeparator();
269268
}
270269
if (result.contains("{{")) {
271-
throw new RuntimeException("Failed to replace all go templating vars, template: " + result);
270+
throw new RuntimeException("Failed to replace all Helm templating vars, template: " + result);
272271
}
273272
return result;
274273
}

0 commit comments

Comments
 (0)