Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

bugfix: plugin node-status and heartbeat don't have schema. #1249

Merged
merged 3 commits into from
Mar 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lua/apisix/plugins/heartbeat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,30 @@ local ngx = ngx
local apisix_heartbeat_addr = "https://www.iresty.com/apisix/heartbeat?"


local schema = {
type = "object",
additionalProperties = false,
}


local _M = {
version = 0.1,
priority = 100,
name = plugin_name,
schema = schema,
}


function _M.check_schema(conf)
local ok, err = core.schema.check(schema, conf)
if not ok then
return false, err
end

return true
end


local function request_apisix_svr(args)
local http_cli, err = http.new()
if err then
Expand Down
17 changes: 17 additions & 0 deletions lua/apisix/plugins/node-status.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@ local apisix_id = core.id.get()
local ipairs = ipairs


local schema = {
type = "object",
additionalProperties = false,
}


local _M = {
version = 0.1,
priority = 1000,
name = plugin_name,
schema = schema,
}


Expand Down Expand Up @@ -67,6 +74,16 @@ local function collect()
end


function _M.check_schema(conf)
local ok, err = core.schema.check(schema, conf)
if not ok then
return false, err
end

return true
end


function _M.api()
return {
{
Expand Down
4 changes: 4 additions & 0 deletions t/admin/global-rules.t
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ passed
--- no_error_log
[error]



=== TEST 3: list global rules
--- config
location /t {
Expand Down Expand Up @@ -155,6 +157,8 @@ passed
--- no_error_log
[error]



=== TEST 4: PATCH global rules
--- config
location /t {
Expand Down
20 changes: 20 additions & 0 deletions t/admin/plugins.t
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,23 @@ GET /apisix/admin/plugins/limit-req
{"properties":{"rate":{"minimum":0,"type":"number"},"burst":{"minimum":0,"type":"number"},"key":{"enum":["remote_addr","server_addr","http_x_real_ip","http_x_forwarded_for"],"type":"string"},"rejected_code":{"minimum":200,"type":"integer"}},"required":["rate","burst","key","rejected_code"],"type":"object"}
--- no_error_log
[error]



=== TEST 4: get plugin node-status schema
--- request
GET /apisix/admin/plugins/node-status
--- response_body
{"additionalProperties":false,"type":"object"}
--- no_error_log
[error]



=== TEST 5: get plugin heartbeat schema
--- request
GET /apisix/admin/plugins/heartbeat
--- response_body
{"additionalProperties":false,"type":"object"}
--- no_error_log
[error]