[COMMON] Enhance the strimzi template function 95/141995/1 master
authormpriyank <priyank.maheshwari@est.tech>
Fri, 5 Sep 2025 13:33:43 +0000 (14:33 +0100)
committermpriyank <priyank.maheshwari@est.tech>
Fri, 5 Sep 2025 13:33:49 +0000 (14:33 +0100)
- enhanced the strimzi helm template function to adhering to k8s object
  naming rules as per https://kubernetes.io/docs/concepts/overview/working-with-objects/names/
- underscores to be replaced with hyphens and prefix and suffix hyphens
  will be trimmed to make it a valid k8s object name

Issue-ID: CPS-2977
Change-Id: I255c257cd97c61c80b2e4e8dec8dd2de0a0d6dfd
Signed-off-by: mpriyank <priyank.maheshwari@est.tech>
kubernetes/common/common/templates/_strimzikafka.tpl

index c3c4cc7..34441c9 100644 (file)
@@ -114,9 +114,9 @@ apiVersion: kafka.strimzi.io/v1beta2
 kind: KafkaTopic
 metadata:
   {{- if (hasKey $topic "strimziTopicName") }}
-  name: {{ ($topic.strimziTopicName) }}-kt
+  name: {{ ($topic.strimziTopicName | replace "_" "-" | trimPrefix "-" | trimSuffix "-") }}-kt
   {{- else }}
-  name: {{ ($topic.name) | lower }}-kt
+  name: {{ ($topic.name | lower | replace "_" "-" | trimPrefix "-" | trimSuffix "-") }}-kt
   {{- end }}
   labels:
     {{- include "common.labels" $ | nindent 4 }}