Skip to content

Commit

Permalink
fix: add array args properly (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoppenheimer authored Feb 27, 2023
1 parent 75b81a0 commit 6493208
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions snap/local/exporter-wrapper.bash
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ then
exit 1
fi


PROPERTIES=$(cat "${SNAP_COMMON}"/exporter.properties)
BOOTSTRAP_SERVERS=$(echo "${PROPERTIES}" | grep bootstrap.servers | sed 's/bootstrap\.servers=//g')
SECURITY_PROTOCOL=$(echo "${PROPERTIES}" | grep security.protocol | sed 's/security\.protocol=//g')
Expand All @@ -18,21 +17,20 @@ PASSWORD=$(echo $SASL_JAAS_CONFIG | grep -oP "password\=\"([a-zA-Z0-9]+)" | cut

for i in $(echo $BOOTSTRAP_SERVERS | tr "," "\n")
do
args+=(" --kafka.server=${i}")
args+=("kafka.server=${i}")
done

if [ -n "$(echo "${SECURITY_PROTOCOL}" | grep "SSL")" ]
then
args+=" --tls.enabled"
args+=" --tls.ca-file=${SNAP_COMMON}/ca.pem"
args+=" --tls.cert-file=${SNAP_COMMON}/server.pem"
args+=" --tls.key-file=${SNAP_COMMON}/server.key"
args+=("tls.enabled")
args+=("tls.ca-file=${SNAP_COMMON}/ca.pem")
args+=("tls.cert-file=${SNAP_COMMON}/server.pem")
args+=("tls.key-file=${SNAP_COMMON}/server.key")
fi

args+=" --sasl.enabled"
args+=" --sasl.mechanism=scram-sha512"
args+=" --sasl.username=${USERNAME}"
args+=" --sasl.password=${PASSWORD}"

"${SNAP}"/opt/kafka/kafka_exporter "${args[@]}"
args+=("sasl.enabled")
args+=("sasl.mechanism=scram-sha512")
args+=("sasl.username=${USERNAME}")
args+=("sasl.password=${PASSWORD}")

"${SNAP}"/opt/kafka/kafka_exporter "${args[@]/#/--}"

0 comments on commit 6493208

Please sign in to comment.