WIP: Adjust runtime envsubst
All checks were successful
Lint Checks / Run linter (pull_request) Successful in 46s
Webapp Test / Run webapp test suite (pull_request) Successful in 4m27s
Deploy Test / Run deploy test suite (pull_request) Successful in 5m57s
K8s Deploy Test / Run deploy test suite on kind/k8s (pull_request) Successful in 7m27s
Smoke Test / Run basic test suite (pull_request) Successful in 4m32s

This commit is contained in:
Thomas E Lackey 2024-02-15 21:05:43 -06:00
parent 26d265360d
commit db086f23c4

View File

@ -18,8 +18,9 @@ if [ -f ".env" ]; then
rm -f $TMP_ENV
fi
for f in $(find . -regex ".*.[tj]sx?$" -type f | grep -v 'node_modules'); do
for e in $(cat "${f}" | tr -s '[:blank:]' '\n' | tr -s '[{},();]' '\n' | egrep -o -e '^"CERC_RUNTIME_ENV_[^\"]+"' -e '^"LACONIC_HOSTED_CONFIG_[^\"]+"'); do
for f in $(find . -type f \( -name '*.html' -or -regex ".*.[tj]s\(x\|on\)?$" \) | grep -v 'node_modules' | grep -v '.git'); do
for e in $(cat "${f}" | tr -s '[:blank:]' '\n' | tr -s '[\\/{},();"]' '\n' | egrep -o -e '^CERC_RUNTIME_ENV_.+'); do
orig_name=$(echo -n "${e}" | sed 's/"//g')
cur_name=$(echo -n "${orig_name}" | sed 's/CERC_RUNTIME_ENV_//g')
cur_val=$(echo -n "\$${cur_name}" | envsubst)
@ -31,3 +32,19 @@ for f in $(find . -regex ".*.[tj]sx?$" -type f | grep -v 'node_modules'); do
sed -i "s/$orig_name/$esc_val/g" $f
done
done
for f in $(find . -type f \( -name '*.html' -or -regex ".*.[tj]s\(x\|on\)?$" \) | grep -v 'node_modules' | grep -v '.git'); do
for cur_name in `env | egrep -o -e '^LACONIC_HOSTED_CONFIG_.+' | cut -d"=" -f1 | sort -u`; do
grep "$e" $f >/dev/null
if [ $? -ne 0 ]; then
continue
fi
cur_val=$(echo -n "\$${cur_name}" | envsubst)
if [ "$CERC_RETAIN_ENV_QUOTES" != "true" ]; then
cur_val=$(sed "s/^[\"']//" <<< "$cur_val" | sed "s/[\"']//")
fi
esc_val=$(sed 's/[&/\]/\\&/g' <<< "$cur_val")
echo "$f: $cur_name=$cur_val"
sed -i "s/$cur_name/$esc_val/g" $f
done
done