Skip to content

Commit 34f8bab

Browse files
karlderkaefereriksjolund
authored andcommitted
feat: add optional filter for environment variables passed to envsubst
closes nginx#705 Co-authored-by: Erik Sjölund <[email protected]>
1 parent ed42652 commit 34f8bab

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

entrypoint/20-envsubst-on-templates.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ auto_envsubst() {
1414
local template_dir="${NGINX_ENVSUBST_TEMPLATE_DIR:-/etc/nginx/templates}"
1515
local suffix="${NGINX_ENVSUBST_TEMPLATE_SUFFIX:-.template}"
1616
local output_dir="${NGINX_ENVSUBST_OUTPUT_DIR:-/etc/nginx/conf.d}"
17+
local filter="${NGINX_ENVSUBST_FILTER:-}"
1718

1819
local template defined_envs relative_path output_path subdir
19-
defined_envs=$(printf '${%s} ' $(xargs -0n1 -a /proc/self/environ sh -c 'echo "$@" | grep -oEm1 "^[^=]+"' --));
20+
defined_envs=$(printf '${%s} ' $(xargs -0n1 -a /proc/self/environ sh -c "echo \"\$@\" | grep -- \"${filter}\" | grep -oEm1 \"^[^=]+\"" --));
2021
[ -d "$template_dir" ] || return 0
2122
if [ ! -w "$output_dir" ]; then
2223
entrypoint_log "$ME: ERROR: $template_dir exists, but $output_dir is not writable"

0 commit comments

Comments
 (0)