You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by sp...@apache.org on 2022/11/30 05:34:30 UTC
[apisix] branch master updated: refactor(env): rename funtion name (#8426)
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 bd6cbef5e refactor(env): rename funtion name (#8426)
bd6cbef5e is described below
commit bd6cbef5e53e7127d6393c8013d66c60a3c1677e
Author: soulbird <zh...@outlook.com>
AuthorDate: Wed Nov 30 13:34:20 2022 +0800
refactor(env): rename funtion name (#8426)
Co-authored-by: soulbird <zh...@gmail.com>
---
apisix/core/env.lua | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/apisix/core/env.lua b/apisix/core/env.lua
index c32f9642a..d8702904a 100644
--- a/apisix/core/env.lua
+++ b/apisix/core/env.lua
@@ -58,14 +58,14 @@ function _M.init()
end
-local function is_env_ref(ref)
+local function is_env_uri(env_uri)
-- Avoid the error caused by has_prefix to cause a crash.
- return type(ref) == "string" and string.has_prefix(upper(ref), ENV_PREFIX)
+ return type(env_uri) == "string" and string.has_prefix(upper(env_uri), ENV_PREFIX)
end
-local function parse_ref(ref)
- local path = sub(ref, #ENV_PREFIX + 1)
+local function parse_env_uri(env_uri)
+ local path = sub(env_uri, #ENV_PREFIX + 1)
local idx = find(path, "/")
if not idx then
return {key = path, sub_key = ""}
@@ -80,12 +80,12 @@ local function parse_ref(ref)
end
-function _M.get(ref)
- if not is_env_ref(ref) then
+function _M.get(env_uri)
+ if not is_env_uri(env_uri) then
return nil
end
- local opts = parse_ref(ref)
+ local opts = parse_env_uri(env_uri)
local main_value = apisix_env_vars[opts.key] or os.getenv(opts.key)
if main_value and opts.sub_key ~= "" then
local vt, err = json.decode(main_value)