From c7a56aa84ac3623e6357adb10ab34ce5a11d92af Mon Sep 17 00:00:00 2001 From: milanhorvath <35398860+milanhorvath@users.noreply.github.com> Date: Mon, 19 Aug 2024 15:17:30 +0200 Subject: [PATCH] feat: add additional extend list for variable replacement --- entrypoint.sh | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 0d95ccc..e940f57 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -22,6 +22,8 @@ else fi IFS=, read -ra config_env_names <<< "$CONFIG_ENV_LIST" +IFS=, read -ra config_env_ext_names <<< "$CONFIG_ENV_EXT_LIST" +config_env_names=( "${config_env_names[@]}" "${config_env_ext_names[@]}" ) # Update environment variables in env.json if [ -f ${DIR_ASSETS}/env.json ]; then @@ -34,7 +36,7 @@ if [ -f ${DIR_ASSETS}/env.json ]; then done echo "Updating ${DIR_ASSETS}/env.json" - for item in $config_env_names; do + for item in ${config_env_names[@]}; do value=$(printf '%s\n' "${!item}") if [[ ! -z "$value" ]]; then echo "Replace '$item' with '$value' in env.json" @@ -42,6 +44,17 @@ if [ -f ${DIR_ASSETS}/env.json ]; then fi done + if [[ ${ADDITIONAL_REPLACE:-false} == true ]]; then + echo "Second update ${DIR_ASSETS}/env.json" + for item in ${config_env_names[@]}; do + value=$(printf '%s\n' "${!item}") + if [[ ! -z "$value" ]]; then + echo "Replace '$item' with '$value' in env.json" + sed -i "s|\${$item}|$value|g" ${DIR_ASSETS}/env.json + fi + done + fi + # Create INJECTED_ENV from env.json envJsonAsString=$(sed -E 's/\$\{.*\}/@UNDEFINED/' ${DIR_ASSETS}/env.json | tr -d "\n") escaped_conf=$(printf '%s\n' "$envJsonAsString" | sed -e 's/[\/&]/\\&/g')