Skip to content

Commit

Permalink
fix: plugin metadata add id value for etcd checker (apache#11452)
Browse files Browse the repository at this point in the history
Signed-off-by: ashing <[email protected]>
  • Loading branch information
ronething authored Aug 1, 2024
1 parent 9980cb3 commit d0af27b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
2 changes: 2 additions & 0 deletions apisix/admin/resource.lua
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ function _M:put(id, conf, sub_path, args)
if not ok then
return 503, {error_msg = err}
end
else
conf.id = id
end

local ttl = nil
Expand Down
2 changes: 1 addition & 1 deletion apisix/plugin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ check_plugin_metadata = function(item)
local ok, err = check_single_plugin_schema(item.id, item,
core.schema.TYPE_METADATA, true)
if ok and enable_gde() then
decrypt_conf(item.name, item, core.schema.TYPE_METADATA)
decrypt_conf(item.id, item, core.schema.TYPE_METADATA)
end

return ok, err
Expand Down
17 changes: 15 additions & 2 deletions apisix/plugins/sls-logger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,28 @@ local schema = {
required = {"host", "port", "project", "logstore", "access_key_id", "access_key_secret"}
}

local metadata_schema = {
type = "object",
properties = {
log_format = {
type = "object"
}
},
}

local _M = {
version = 0.1,
priority = 406,
name = plugin_name,
schema = batch_processor_manager:wrap_schema(schema),
metadata_schema = metadata_schema,
}

function _M.check_schema(conf)
return core.schema.check(schema, conf)
function _M.check_schema(conf,schema_type)
if schema_type == core.schema.TYPE_METADATA then
return core.schema.check(metadata_schema, conf)
end
return core.schema.check(schema, conf)
end

local function send_tcp_data(route_conf, log_message)
Expand Down
4 changes: 2 additions & 2 deletions t/admin/plugin-metadata.t
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ qr/\{"error_msg":"invalid configuration: property \\"ikey\\" is required"\}/
}
}
--- response_body
{"key":"/apisix/plugin_metadata/example-plugin","value":{"ikey":1,"skey":"val"}}
{"key":"/apisix/plugin_metadata/example-plugin","value":{"id":"example-plugin","ikey":1,"skey":"val"}}
--- request
GET /t

Expand Down Expand Up @@ -305,7 +305,7 @@ GET /t
}
}
--- response_body
{"key":"/apisix/plugin_metadata/example-plugin","value":{"ikey":1,"skey":"val"}}
{"key":"/apisix/plugin_metadata/example-plugin","value":{"id":"example-plugin","ikey":1,"skey":"val"}}
--- request
GET /t

Expand Down

0 comments on commit d0af27b

Please sign in to comment.