From ac18e6acf9bbc161147454e6a86bde086c9b8f6d Mon Sep 17 00:00:00 2001 From: Tin Lam Date: Fri, 6 Dec 2019 23:58:44 -0600 Subject: [PATCH] Fix feature gate envvar overriding Currently using envsubst to perform substitution of value overrides in the feature gate caused conflicts as gotpl gets templated into those overrides. This adds in '%%%REPLACE_${var}%%%' and uses sed to perform the substitution instead to address the issue. Change-Id: I9d3d630b53a2f3d828866229a5072bb04440ae15 Signed-off-by: Tin Lam --- ceph-rgw/values_overrides/netpol.yaml | 4 ++-- mariadb/values_overrides/netpol.yaml | 4 ++-- memcached/values_overrides/netpol.yaml | 4 ++-- rabbitmq/values_overrides/netpol.yaml | 4 ++-- tools/deployment/common/get-values-overrides.sh | 11 +++++++++-- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/ceph-rgw/values_overrides/netpol.yaml b/ceph-rgw/values_overrides/netpol.yaml index 4c0973818..b9f0898cd 100644 --- a/ceph-rgw/values_overrides/netpol.yaml +++ b/ceph-rgw/values_overrides/netpol.yaml @@ -14,7 +14,7 @@ network_policy: port: 443 - to: - ipBlock: - cidr: $API_ADDR/32 + cidr: %%%REPLACE_API_ADDR%%%/32 ports: - protocol: TCP - port: $API_PORT + port: %%%REPLACE_API_PORT%%% diff --git a/mariadb/values_overrides/netpol.yaml b/mariadb/values_overrides/netpol.yaml index f5ae02ebf..7d6122be8 100644 --- a/mariadb/values_overrides/netpol.yaml +++ b/mariadb/values_overrides/netpol.yaml @@ -5,7 +5,7 @@ network_policy: egress: - to: - ipBlock: - cidr: $API_ADDR/32 + cidr: %%%REPLACE_API_ADDR%%%/32 ports: - protocol: TCP - port: $API_PORT + port: %%%REPLACE_API_PORT%%% diff --git a/memcached/values_overrides/netpol.yaml b/memcached/values_overrides/netpol.yaml index 204e64cce..4a59c5277 100644 --- a/memcached/values_overrides/netpol.yaml +++ b/memcached/values_overrides/netpol.yaml @@ -5,7 +5,7 @@ network_policy: egress: - to: - ipBlock: - cidr: $API_ADDR/32 + cidr: %%%REPLACE_API_ADDR%%%/32 ports: - protocol: TCP - port: $API_PORT + port: %%%REPLACE_API_PORT%%% diff --git a/rabbitmq/values_overrides/netpol.yaml b/rabbitmq/values_overrides/netpol.yaml index 497955842..d56e425c4 100644 --- a/rabbitmq/values_overrides/netpol.yaml +++ b/rabbitmq/values_overrides/netpol.yaml @@ -102,7 +102,7 @@ network_policy: # port: 35197 - to: - ipBlock: - cidr: $API_ADDR/32 + cidr: %%%REPLACE_API_ADDR%%%/32 ports: - protocol: TCP - port: $API_PORT + port: %%%REPLACE_API_PORT%%% diff --git a/tools/deployment/common/get-values-overrides.sh b/tools/deployment/common/get-values-overrides.sh index ef1b588f3..c497e30e0 100755 --- a/tools/deployment/common/get-values-overrides.sh +++ b/tools/deployment/common/get-values-overrides.sh @@ -47,14 +47,21 @@ function combination () { done } +function replace_variables() { + for key in $(env); do + local arr=( $(echo $key | awk -F'=' '{ print $1, $2}') ) + sed -i "s#%%%REPLACE_${arr[0]}%%%#${arr[1]}#g" $@ + done +} + function override_file_args () { OVERRIDE_ARGS="" echoerr "We will attempt to use values-override files with the following paths:" for FILE in $(combination ${1//,/ } | uniq | tac); do FILE_PATH="${HELM_CHART_ROOT_PATH}/${HELM_CHART}/values_overrides/${FILE}.yaml" if [ -f "${FILE_PATH}" ]; then - envsubst < ${FILE_PATH} > /tmp/${HELM_CHART}-${FILE}.yaml - OVERRIDE_ARGS+=" --values=/tmp/${HELM_CHART}-${FILE}.yaml " + replace_variables ${FILE_PATH} + OVERRIDE_ARGS+=" --values=${FILE_PATH} " fi echoerr "${FILE_PATH}" done