Skip to content

Commit

Permalink
bugfix: plugin node-status and heartbeat don't have schema. (apache#1249
Browse files Browse the repository at this point in the history
)
  • Loading branch information
membphis authored and SaberMaster committed Jun 30, 2020
1 parent 1b78ff7 commit fd4badc
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
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
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]

0 comments on commit fd4badc

Please sign in to comment.