From 5dc0c2ba5dd874f488df96455a13a6d2dc2bb8c5 Mon Sep 17 00:00:00 2001 From: Ryanne Dolan Date: Thu, 31 Aug 2023 15:44:01 -0500 Subject: [PATCH] Bug fix: handle capitals in Kafka topics (#50) --- .../com/linkedin/hoptimator/catalog/kafka/KafkaTopic.java | 6 +++--- .../linkedin/hoptimator/catalog/kafka/KafkaTopicAcl.java | 3 +++ .../src/main/resources/KafkaTopic.yaml.template | 2 +- .../src/main/resources/KafkaTopicAcl.yaml.template | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/hoptimator-kafka-adapter/src/main/java/com/linkedin/hoptimator/catalog/kafka/KafkaTopic.java b/hoptimator-kafka-adapter/src/main/java/com/linkedin/hoptimator/catalog/kafka/KafkaTopic.java index e91ac07..7d096b2 100644 --- a/hoptimator-kafka-adapter/src/main/java/com/linkedin/hoptimator/catalog/kafka/KafkaTopic.java +++ b/hoptimator-kafka-adapter/src/main/java/com/linkedin/hoptimator/catalog/kafka/KafkaTopic.java @@ -2,14 +2,14 @@ import com.linkedin.hoptimator.catalog.Resource; -import java.util.Optional; -import java.util.Collections; +import java.util.Locale; import java.util.Map; class KafkaTopic extends Resource { - public KafkaTopic(String topicName, Map clientOverrides) { + KafkaTopic(String topicName, Map clientOverrides) { super("KafkaTopic"); export("topicName", topicName); + export("topicNameLowerCase", topicName.toLowerCase(Locale.ROOT)); export("clientOverrides", clientOverrides); } } diff --git a/hoptimator-kafka-adapter/src/main/java/com/linkedin/hoptimator/catalog/kafka/KafkaTopicAcl.java b/hoptimator-kafka-adapter/src/main/java/com/linkedin/hoptimator/catalog/kafka/KafkaTopicAcl.java index 56054f1..a5b8d55 100644 --- a/hoptimator-kafka-adapter/src/main/java/com/linkedin/hoptimator/catalog/kafka/KafkaTopicAcl.java +++ b/hoptimator-kafka-adapter/src/main/java/com/linkedin/hoptimator/catalog/kafka/KafkaTopicAcl.java @@ -2,10 +2,13 @@ import com.linkedin.hoptimator.catalog.Resource; +import java.util.Locale; + class KafkaTopicAcl extends Resource { public KafkaTopicAcl(String topicName, String principal, String method) { super("KafkaTopicAcl"); export("topicName", topicName); + export("topicNameLowerCase", topicName.toLowerCase(Locale.ROOT)); export("principal", principal); export("method", method); } diff --git a/hoptimator-kafka-adapter/src/main/resources/KafkaTopic.yaml.template b/hoptimator-kafka-adapter/src/main/resources/KafkaTopic.yaml.template index fa0cb26..734703f 100644 --- a/hoptimator-kafka-adapter/src/main/resources/KafkaTopic.yaml.template +++ b/hoptimator-kafka-adapter/src/main/resources/KafkaTopic.yaml.template @@ -1,7 +1,7 @@ apiVersion: hoptimator.linkedin.com/v1alpha1 kind: KafkaTopic metadata: - name: {{topicName}} + name: {{topicNameLowerCase}} namespace: {{pipeline.namespace}} spec: topicName: {{topicName}} diff --git a/hoptimator-kafka-adapter/src/main/resources/KafkaTopicAcl.yaml.template b/hoptimator-kafka-adapter/src/main/resources/KafkaTopicAcl.yaml.template index 9d1297b..f69c870 100644 --- a/hoptimator-kafka-adapter/src/main/resources/KafkaTopicAcl.yaml.template +++ b/hoptimator-kafka-adapter/src/main/resources/KafkaTopicAcl.yaml.template @@ -1,11 +1,11 @@ apiVersion: hoptimator.linkedin.com/v1alpha1 kind: Acl metadata: - name: {{topicName}}-acl-{{id}} + name: {{topicNameLowerCase}}-acl-{{id}} namespace: {{pipeline.namespace}} spec: resource: kind: KafkaTopic - name: {{topicName}} + name: {{topicNameLowerCase}} method: {{method}} principal: {{principal}}