SumoLogic / sumologic-collector-docker

A Sumo Logic collector for Docker.
Apache License 2.0
69 stars 55 forks source link

Handle emptry string for environment variable #72

Closed jmreicha closed 5 years ago

jmreicha commented 5 years ago

Fixes https://github.com/SumoLogic/sumologic-collector-docker/issues/70 by adding logic for handling an empty environment variable, in order to create custom collector name with no prefix.

maimaisie commented 5 years ago

Good catch. Actually the fix might be as simple as removing the colon. So it would become

SUMO_COLLECTOR_NAME=${SUMO_COLLECTOR_NAME_PREFIX='collector_container-'}${SUMO_COLLECTOR_NAME:=`cat /etc/hostname`}

see https://stackoverflow.com/a/26899206 specifically this case:

EGGS=
: ${EGGS=spam}
echo 3 $EGGS     # 3        (set, but blank -> leaves alone)
EGGS=
: ${EGGS:=spam}
echo 4 $EGGS     # 4 spam
jmreicha commented 5 years ago

@maimaisie ah thank you, I was thinking there was an easier way to do it, just couldn't see it. I will update the PR.

maimaisie commented 5 years ago

Thanks for fixing! We will run some tests before releasing new builds.