This is an automated email from the ASF dual-hosted git repository. membphis 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 2457aa1 feat: check if Admin API is used with etcd config_center (#3018) 2457aa1 is described below commit 2457aa1e4da89982f86c84224392e1350f8a1337 Author: 罗泽轩 <spacewander...@gmail.com> AuthorDate: Sun Dec 13 23:08:15 2020 +0800 feat: check if Admin API is used with etcd config_center (#3018) --- .travis/apisix_cli_test.sh | 15 +++++++++++++++ apisix/cli/ops.lua | 6 ++++++ doc/stand-alone.md | 2 +- doc/zh-cn/stand-alone.md | 2 +- 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/.travis/apisix_cli_test.sh b/.travis/apisix_cli_test.sh index de1ad58..5b43330 100755 --- a/.travis/apisix_cli_test.sh +++ b/.travis/apisix_cli_test.sh @@ -918,3 +918,18 @@ if ! echo "$out" | grep 'authentication is not enabled'; then fi echo "passed: properly handle the error when connecting to etcd without auth" + +# Admin API can only be used with etcd config_center +echo ' +apisix: + enable_admin: true + config_center: yaml +' > conf/config.yaml + +out=$(make init 2>&1 || true) +if ! echo "$out" | grep "Admin API can only be used with etcd config_center"; then + echo "failed: Admin API can only be used with etcd config_center" + exit 1 +fi + +echo "passed: Admin API can only be used with etcd config_center" diff --git a/apisix/cli/ops.lua b/apisix/cli/ops.lua index c3e72cb..fe663b5 100644 --- a/apisix/cli/ops.lua +++ b/apisix/cli/ops.lua @@ -176,6 +176,12 @@ Please modify "admin_key" in conf/config.yaml . end end + if yaml_conf.apisix.enable_admin and + yaml_conf.apisix.config_center == "yaml" + then + util.die("ERROR: Admin API can only be used with etcd config_center.\n") + end + local or_ver = util.execute_cmd("openresty -V 2>&1") local with_module_status = true if or_ver and not or_ver:find("http_stub_status_module", 1, true) then diff --git a/doc/stand-alone.md b/doc/stand-alone.md index 9d0a13b..44c5428 100644 --- a/doc/stand-alone.md +++ b/doc/stand-alone.md @@ -43,7 +43,7 @@ apisix: # `/your_path/conf/apisix.yaml` ``` -In addition, since the current Admin API is based on the etcd configuration center solution, the Admin API will not actually work when the Stand-alone mode is enabled. +In addition, since the current Admin API is based on the etcd configuration center solution, enable Admin API is not allowed when the Stand-alone mode is enabled. ## How to config rules diff --git a/doc/zh-cn/stand-alone.md b/doc/zh-cn/stand-alone.md index fd08c23..03ce3e1 100644 --- a/doc/zh-cn/stand-alone.md +++ b/doc/zh-cn/stand-alone.md @@ -47,7 +47,7 @@ apisix: ``` 此外由于目前 Admin API 都是基于 etcd 配置中心解决方案,当开启 Stand-alone 模式后, -Admin API 实际将不起作用。 +Admin API 将不再被允许使用。 ## 如何配置规则