Skip to content

Commit

Permalink
Remove unnecessary cat $FINAL_CONFIG
Browse files Browse the repository at this point in the history
  • Loading branch information
cYKatherine committed Jan 8, 2024
1 parent 42d80ec commit 70084d2
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions scripts/gcp-oidc/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@
#
# This script must be compatible with Ash (provided in eclipse-temurin Docker image) and Bash

# for number/boolean
# https://jqlang.github.io/jq/manual/
# --argjson foo 123 will bind $foo to 123.
function jq_inplace_update_json() {
local file=$1
local field=$2
local value=$3
jq --argjson v "$value" ".$field = \$v" "$file" > tmp.json && mv tmp.json "$file"
}


# -- set API tokens
if [ -z "${API_TOKEN_SECRET_NAME}" ]; then
echo "API_TOKEN_SECRET_NAME cannot be empty"
Expand Down Expand Up @@ -37,17 +48,16 @@ fi
# -- replace base URLs if both CORE_BASE_URL and OPTOUT_BASE_URL are provided
# -- using hardcoded domains is fine because they should not be changed frequently
if [ -n "${CORE_BASE_URL}" -a -n "${OPTOUT_BASE_URL}" -a "${DEPLOYMENT_ENVIRONMENT}" != 'prod' ]; then
echo "-- replacing URLs by ${CORE_BASE_URL} and ${OPTOUT_BASE_URL}"
sed -i "s#https://core-integ.uidapi.com#${CORE_BASE_URL}#g" ${FINAL_CONFIG}
echo "-- replacing URLs by ${CORE_BASE_URL} and ${OPTOUT_BASE_URL}"
sed -i "s#https://core-integ.uidapi.com#${CORE_BASE_URL}#g" ${FINAL_CONFIG}

sed -i "s#https://optout-integ.uidapi.com#${OPTOUT_BASE_URL}#g" ${FINAL_CONFIG}
sed -i "s#https://optout-integ.uidapi.com#${OPTOUT_BASE_URL}#g" ${FINAL_CONFIG}
fi

# -- replace `enforce_https` value to ENFORCE_HTTPS if provided
if [ "${ENFORCE_HTTPS}" == false ]; then
echo "-- replacing enforce_https by ${ENFORCE_HTTPS}"
cat "${FINAL_CONFIG}"
sed '/enforce_https/s/true/false/' ${FINAL_CONFIG}
echo "-- replacing enforce_https by ${ENFORCE_HTTPS}"
jq_inplace_update_json $FINAL_CONFIG enforce_https $ENFORCE_HTTPS
fi

cat $FINAL_CONFIG
Expand Down

0 comments on commit 70084d2

Please sign in to comment.