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/08/26 07:39:38 UTC
[apisix] branch master updated: feat: allow APISIX_PROFILE to be an empty string (#7240)
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 4f18a5e2a feat: allow APISIX_PROFILE to be an empty string (#7240)
4f18a5e2a is described below
commit 4f18a5e2a85cb9332a23d2e6d3f749dc3cc2d587
Author: Crazy_Coder <su...@gmail.com>
AuthorDate: Fri Aug 26 15:39:29 2022 +0800
feat: allow APISIX_PROFILE to be an empty string (#7240)
---
apisix/core/profile.lua | 4 ++--
t/core/profile.t | 18 ++++++++++++++++++
2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/apisix/core/profile.lua b/apisix/core/profile.lua
index b4c4cfaa9..389a9d42c 100644
--- a/apisix/core/profile.lua
+++ b/apisix/core/profile.lua
@@ -21,7 +21,7 @@
local _M = {
version = 0.1,
- profile = os.getenv("APISIX_PROFILE"),
+ profile = os.getenv("APISIX_PROFILE") or "",
apisix_home = (ngx and ngx.config.prefix()) or ""
}
@@ -40,7 +40,7 @@ local _M = {
-- local local_conf_path = profile:yaml_path("config")
function _M.yaml_path(self, file_name)
local file_path = self.apisix_home .. "conf/" .. file_name
- if self.profile and file_name ~= "config-default" then
+ if self.profile ~= "" and file_name ~= "config-default" then
file_path = file_path .. "-" .. self.profile
end
diff --git a/t/core/profile.t b/t/core/profile.t
index 663dcf1be..3e28f9706 100644
--- a/t/core/profile.t
+++ b/t/core/profile.t
@@ -32,3 +32,21 @@ __DATA__
--- request
GET /t
--- error_code: 404
+
+
+
+=== TEST 2: set env "APISIX_PROFILE" to Empty String
+--- config
+ location /t {
+ content_by_lua_block {
+ local profile = require("apisix.core.profile")
+ profile.apisix_home = "./test/"
+ profile.profile = ""
+ local local_conf_path = profile:yaml_path("config")
+ ngx.say(local_conf_path)
+ }
+ }
+--- request
+GET /t
+--- response_body
+./test/conf/config.yaml