From d7a4005adc8d30db5184168bc27e0a36ba79073e Mon Sep 17 00:00:00 2001 From: rjshrjndrn Date: Tue, 21 Jun 2022 09:39:12 +0200 Subject: [PATCH] refactor(helm): format file. Signed-off-by: rjshrjndrn --- scripts/helmcharts/openreplay/files/kafka.sh | 50 ++++++++++---------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/scripts/helmcharts/openreplay/files/kafka.sh b/scripts/helmcharts/openreplay/files/kafka.sh index 8f24952f2..f7ad0b8ec 100644 --- a/scripts/helmcharts/openreplay/files/kafka.sh +++ b/scripts/helmcharts/openreplay/files/kafka.sh @@ -1,42 +1,44 @@ #!/bin/bash set -e + # Default to 4 days. RETENTION_TIME=${RETENTION_TIME:-345600000} + topics=( - "raw" - "raw-ios" - "trigger" - "cache" - "analytics" - ) + "raw" + "raw-ios" + "trigger" + "cache" + "analytics" +) touch /tmp/config.txt if [[ $KAFKA_SSL == "true" ]]; then - echo 'security.protocol=SSL' > /tmp/config.txt + echo 'security.protocol=SSL' > /tmp/config.txt fi function init() { - echo "Initializing kafka" - for topic in ${topics[*]}; do - echo "Creating topic: $topic" - # TODO: Have to check an idempotent way of creating topics. - kafka-topics.sh --create --bootstrap-server ${KAFKA_HOST}:${KAFKA_PORT} --replication-factor 2 --partitions 16 --topic ${topic} --command-config /tmp/config.txt || true - kafka-configs.sh --bootstrap-server ${KAFKA_HOST}:${KAFKA_PORT} --entity-type topics --alter --add-config retention.ms=${RETENTION_TIME} --entity-name=${topic} --command-config /tmp/config.txt || true - done + echo "Initializing kafka" + for topic in ${topics[*]}; do + echo "Creating topic: $topic" + # TODO: Have to check an idempotent way of creating topics. + kafka-topics.sh --create --bootstrap-server ${KAFKA_HOST}:${KAFKA_PORT} --replication-factor 2 --partitions 16 --topic ${topic} --command-config /tmp/config.txt || true + kafka-configs.sh --bootstrap-server ${KAFKA_HOST}:${KAFKA_PORT} --entity-type topics --alter --add-config retention.ms=${RETENTION_TIME} --entity-name=${topic} --command-config /tmp/config.txt || true + done } # /bin/bash kafka.sh migrate $migration_versions case "$1" in - migrate) - init - ;; - init) - init - ;; - *) - echo "Unknown operation for kafka migration; exiting." - exit 1 - ;; + migrate) + init + ;; + init) + init + ;; + *) + echo "Unknown operation for kafka migration; exiting." + exit 1 + ;; esac