From bc9cd2f34c7450a5d961cc01f836014e8393a19c Mon Sep 17 00:00:00 2001
From: Simon Ehrenstein <simon.ehrenstein@gmail.com>
Date: Fri, 18 Feb 2022 16:08:47 +0100
Subject: [PATCH] Fix go templates

---
 helm/Chart.yaml                               |  2 +-
 helm/templates/strimzi/kafka-cluster.yaml     | 22 +++++++++++++++++++
 .../strimzi/kafka-exporter-podmonitor.yaml    |  4 +++-
 .../strimzi/kafka-metrics-configmap.yaml      |  4 +++-
 helm/templates/strimzi/kafka-podmonitor.yaml  |  2 ++
 helm/values.yaml                              |  6 ++---
 6 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/helm/Chart.yaml b/helm/Chart.yaml
index d19c40610..77e867e55 100644
--- a/helm/Chart.yaml
+++ b/helm/Chart.yaml
@@ -27,7 +27,7 @@ dependencies:
   - name: strimzi-kafka-operator
     version: 0.27.1
     repository: https://strimzi.io/charts/
-    condition: strimzi-kafka-operator.enabled
+    condition: strimzi.enabled
 
 
 version: 0.7.0-SNAPSHOT
diff --git a/helm/templates/strimzi/kafka-cluster.yaml b/helm/templates/strimzi/kafka-cluster.yaml
index cb427681e..ab0126f28 100644
--- a/helm/templates/strimzi/kafka-cluster.yaml
+++ b/helm/templates/strimzi/kafka-cluster.yaml
@@ -1,3 +1,4 @@
+{{- if .Values.strimzi.enabled -}}
 apiVersion: kafka.strimzi.io/v1beta2
 kind: Kafka
 metadata:
@@ -5,6 +6,22 @@ metadata:
 spec:
   kafka:
     jmxOptions: {}
+    {{- with .Values.strimzi.kafka.listeners }}
+    listeners:
+      {{- toYaml . | nindent 6 }}
+    {{- end }}
+    {{- with .Values.strimzi.kafka.replicas }}
+    replicas:
+      {{- toYaml . | nindent 6 }}
+    {{- end }}
+    {{- with .Values.strimzi.kafka.config }}
+    config:
+      {{- toYaml . | nindent 6 }}
+    {{- end }}
+    {{- with .Values.strimzi.kafka.jvmOptions }}
+    jvmOptions:
+      {{- toYaml . | nindent 6 }}
+    {{- end }}
     storage:
       type: ephemeral
     metricsConfig:
@@ -17,5 +34,10 @@ spec:
   kafkaExporter: {}
 
   zookeeper:
+    {{- with .Values.strimzi.zookeeper.replicas }}
+    replicas:
+      {{- toYaml . | nindent 6 }}
+    {{- end }}
     storage:
       type: ephemeral
+{{- end }}
\ No newline at end of file
diff --git a/helm/templates/strimzi/kafka-exporter-podmonitor.yaml b/helm/templates/strimzi/kafka-exporter-podmonitor.yaml
index 679b9dbdb..016cba1bc 100644
--- a/helm/templates/strimzi/kafka-exporter-podmonitor.yaml
+++ b/helm/templates/strimzi/kafka-exporter-podmonitor.yaml
@@ -1,3 +1,4 @@
+{{- if .Values.strimzi.enabled -}}
 apiVersion: monitoring.coreos.com/v1
 kind: PodMonitor
 metadata:
@@ -14,4 +15,5 @@ spec:
       - default
   podMetricsEndpoints:
   - path: /metrics
-    port: tcp-prometheus
\ No newline at end of file
+    port: tcp-prometheus
+{{- end }}
\ No newline at end of file
diff --git a/helm/templates/strimzi/kafka-metrics-configmap.yaml b/helm/templates/strimzi/kafka-metrics-configmap.yaml
index 1ce8c3d08..179dce05d 100644
--- a/helm/templates/strimzi/kafka-metrics-configmap.yaml
+++ b/helm/templates/strimzi/kafka-metrics-configmap.yaml
@@ -1,3 +1,4 @@
+{{- if .Values.strimzi.enabled -}}
 kind: ConfigMap
 apiVersion: v1
 metadata:
@@ -128,4 +129,5 @@ data:
       name: kafka_$1_$2_$3
       type: GAUGE
       labels:
-        quantile: "0.$4"
\ No newline at end of file
+        quantile: "0.$4"
+{{- end }}
\ No newline at end of file
diff --git a/helm/templates/strimzi/kafka-podmonitor.yaml b/helm/templates/strimzi/kafka-podmonitor.yaml
index 27e89c8b6..30d66acc1 100644
--- a/helm/templates/strimzi/kafka-podmonitor.yaml
+++ b/helm/templates/strimzi/kafka-podmonitor.yaml
@@ -1,3 +1,4 @@
+{{- if .Values.strimzi.enabled -}}
 apiVersion: monitoring.coreos.com/v1
 kind: PodMonitor
 metadata:
@@ -15,3 +16,4 @@ spec:
   podMetricsEndpoints:
   - path: /metrics
     port: tcp-prometheus
+{{- end }}
\ No newline at end of file
diff --git a/helm/values.yaml b/helm/values.yaml
index cd2fe69d5..a8826b040 100644
--- a/helm/values.yaml
+++ b/helm/values.yaml
@@ -137,7 +137,6 @@ cp-helm-charts:
       nodePort: 30099
       annotations: {}
 
-
     kafka:
       bootstrapServers: theodolite-strimzi-kafka-bootstrap:9092
 
@@ -156,9 +155,8 @@ cp-helm-charts:
   ## The interval between refreshing metrics
   pollIntervalSeconds: 15
 
-strimzi-kafka-operator:
+strimzi:
   enabled: true
-
   kafka:
     listeners:
       - name: plain
@@ -255,7 +253,7 @@ prometheus:
 operator:
   enabled: true
   
-  image: ghcr.io/cau-se/theodolite
+  image: sehrenstein/theodolite-operator-jvm # old: ghcr.io/cau-se/theodolite
   imageTag: latest
   imagePullPolicy: Always
 
-- 
GitLab