You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "spacewander (via GitHub)" <gi...@apache.org> on 2023/02/21 09:09:43 UTC
[GitHub] [apisix] spacewander commented on a diff in pull request #8898: feat(cli): support reserved environment variable "APISIX_DEPLOYMENT_E…
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: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org