spacewander commented on code in PR #8898:
URL: https://github.com/apache/apisix/pull/8898#discussion_r1112769350


##########
t/cli/test_main.sh:
##########
@@ -211,6 +211,17 @@ fi
 
 echo "passed: resolve variables"
 
+# support reserved environment variable APISIX_DEPLOYMENT_ETCD_HOST
+
+echo '' > conf/config.yaml
+out=$(APISIX_DEPLOYMENT_ETCD_HOST='["http://127.0.0.1:2333";]' make init 2>&1 
|| true)

Review Comment:
   Have you tested it with ./bin/apisix start?



##########
t/cli/test_main.sh:
##########
@@ -211,6 +211,17 @@ fi
 
 echo "passed: resolve variables"
 
+# support reserved environment variable APISIX_DEPLOYMENT_ETCD_HOST
+
+echo '' > conf/config.yaml

Review Comment:
   Let's add a config to check if the env can override config



##########
apisix/cli/file.lua:
##########
@@ -115,6 +117,24 @@ end
 _M.resolve_conf_var = resolve_conf_var
 
 
+local function replace_by_reserved_env_vars(conf)
+    -- TODO: support more reserved environment variables
+    local v = getenv("APISIX_DEPLOYMENT_ETCD_HOST")
+    if v and conf["deployment"] and conf["deployment"]["etcd"] then
+        local val, _, err = dkjson.decode(v)
+        if err or not val then
+            print("parse ${APISIX_DEPLOYMENT_ETCD_HOST} failed, error:", err)
+            return
+        end
+
+        conf["deployment"]["etcd"]["host"] = val
+    end
+end
+
+
+_M.replace_by_reserved_env_vars = replace_by_reserved_env_vars

Review Comment:
   Why export this function?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to