This is an automated email from the ASF dual-hosted git repository.

spacewander pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 39840f9  feat: allow whitespace-wrapped variables in config.yaml 
(#2811)
39840f9 is described below

commit 39840f9d8de5d77f6c1d152a1125faabda49e19f
Author: 罗泽轩 <[email protected]>
AuthorDate: Tue Nov 24 16:06:11 2020 +0800

    feat: allow whitespace-wrapped variables in config.yaml (#2811)
---
 .travis/apisix_cli_test.sh | 15 +++++++++++++++
 bin/apisix                 |  2 +-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/.travis/apisix_cli_test.sh b/.travis/apisix_cli_test.sh
index f0ee7aa..2e142fe 100755
--- a/.travis/apisix_cli_test.sh
+++ b/.travis/apisix_cli_test.sh
@@ -196,6 +196,21 @@ fi
 
 echo "passed: resolve variables as boolean"
 
+echo '
+nginx_config:
+    envs:
+        - ${{ var_test}}_${{ FOO }}
+' > conf/config.yaml
+
+var_test=TEST FOO=bar make init
+
+if ! grep "env TEST_bar;" conf/nginx.conf > /dev/null; then
+    echo "failed: failed to resolve variables wrapped with whitespace"
+    exit 1
+fi
+
+echo "passed: resolve variables wrapped with whitespace"
+
 # check nameserver imported
 git checkout conf/config.yaml
 
diff --git a/bin/apisix b/bin/apisix
index c2de2b5..d69a7c7 100755
--- a/bin/apisix
+++ b/bin/apisix
@@ -94,7 +94,7 @@ local function resolve_conf_var(conf)
             local var_used = false
             -- we use '${{var}}' because '$var' and '${var}' are taken
             -- by Nginx
-            local new_val = val:gsub("%$%{%{([%w_]+)%}%}", function(var)
+            local new_val = val:gsub("%$%{%{%s*([%w_]+)%s*%}%}", function(var)
                 local v = os.getenv(var)
                 if v then
                     var_used = true

Reply via email to