From dafe22e7b3f743cd2134d0915431cf7658434352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Tue, 28 Jun 2022 19:20:21 +0200 Subject: [PATCH] Add basic kafkadocker command to run kafka in docker --- symlinks/bin/kafkadocker | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 symlinks/bin/kafkadocker diff --git a/symlinks/bin/kafkadocker b/symlinks/bin/kafkadocker new file mode 100755 index 0000000..8741859 --- /dev/null +++ b/symlinks/bin/kafkadocker @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +# Runs commands for kafka CLI in docker +POSITIONAL=() +NETWORK=docker_default +HOST=kafka +PORT=9092 +SKIP_SERVER=0 +while [[ $# -gt 0 ]]; do + key="$1" + + case $key in + -n|--network) + NETWORK=$2 + shift # past argument + shift # past value + ;; + -h|--host) + HOST=$2 + shift # past argument + shift # past value + ;; + -p|--port) + PORT=$2 + shift # past argument + shift # past value + ;; + --no-server) + SKIP_SERVER=1 + shift # past argument + ;; + *) # unknown option + POSITIONAL+=("$1") # save it in an array for later + shift # past argument + ;; + esac +done + +if [ $SKIP_SERVER -eq 0 ]; then + POSITIONAL+=("--bootstrap-server $HOST:$PORT") +fi + +echo "docker run -it --rm --network $NETWORK bitnami/kafka:latest ${POSITIONAL[@]} " +docker run -it --rm --network $NETWORK bitnami/kafka:latest ${POSITIONAL[@]}