From 34b2a965cb84f5a6006ea2aaff35f56bc43e71e1 Mon Sep 17 00:00:00 2001 From: Bryan Strassner Date: Wed, 16 Jan 2019 13:34:40 -0600 Subject: [PATCH] Handle root vHost declaration If the source chart does not declare a vHost value, or uses the value of "/", the script would fail upon trying to declare the vhost. This change avoids the declaration of the "/" vhost, and continues with setting the specified user with permissions to "/" Change-Id: I28619c0aef22049c632c92a2f9a9d3831f8c284c --- .../templates/scripts/_rabbit-init.sh.tpl | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/helm-toolkit/templates/scripts/_rabbit-init.sh.tpl b/helm-toolkit/templates/scripts/_rabbit-init.sh.tpl index 84d58593cc..2c5bd5b1a8 100644 --- a/helm-toolkit/templates/scripts/_rabbit-init.sh.tpl +++ b/helm-toolkit/templates/scripts/_rabbit-init.sh.tpl @@ -45,6 +45,8 @@ RABBITMQ_PASSWORD=$(echo "${RABBITMQ_USER_CONNECTION}" | \ RABBITMQ_VHOST=$(echo "${RABBITMQ_USER_CONNECTION}" | \ awk -F'[@]' '{print $2}' | \ awk -F'[:/]' '{print $3}') +# Resolve vHost to / if no value is set +RABBITMQ_VHOST="${RABBITMQ_VHOST:-/}" function rabbitmqadmin_cli () { rabbitmqadmin \ @@ -62,10 +64,15 @@ rabbitmqadmin_cli \ password="${RABBITMQ_PASSWORD}" \ tags="user" -echo "Managing: vHost: ${RABBITMQ_VHOST}" -rabbitmqadmin_cli \ - declare vhost \ - name="${RABBITMQ_VHOST}" +if [ "${RABBITMQ_VHOST}" != "/" ] +then + echo "Managing: vHost: ${RABBITMQ_VHOST}" + rabbitmqadmin_cli \ + declare vhost \ + name="${RABBITMQ_VHOST}" +else + echo "Skipping root vHost declaration: vHost: ${RABBITMQ_VHOST}" +fi echo "Managing: Permissions: ${RABBITMQ_USERNAME} on ${RABBITMQ_VHOST}" rabbitmqadmin_cli \