45 lines
906 B
Bash
Executable File
45 lines
906 B
Bash
Executable File
#!/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[@]}
|