This is an automated email from the ASF dual-hosted git repository. wenming 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 d0af27b10 fix: plugin metadata add id value for etcd checker (#11452) d0af27b10 is described below commit d0af27b10a9bbf0e2f15b53cf70f2e7a121c5afd Author: Ashing Zheng <axing...@gmail.com> AuthorDate: Thu Aug 1 11:33:39 2024 +0800 fix: plugin metadata add id value for etcd checker (#11452) Signed-off-by: ashing <axing...@gmail.com> --- apisix/admin/resource.lua | 2 ++ apisix/plugin.lua | 2 +- apisix/plugins/sls-logger.lua | 17 +++++++++++++++-- t/admin/plugin-metadata.t | 4 ++-- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/apisix/admin/resource.lua b/apisix/admin/resource.lua index b03f1b069..2a8771602 100644 --- a/apisix/admin/resource.lua +++ b/apisix/admin/resource.lua @@ -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 diff --git a/apisix/plugin.lua b/apisix/plugin.lua index cabcda176..3d3c4b39b 100644 --- a/apisix/plugin.lua +++ b/apisix/plugin.lua @@ -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 diff --git a/apisix/plugins/sls-logger.lua b/apisix/plugins/sls-logger.lua index 114a20969..819f0841b 100644 --- a/apisix/plugins/sls-logger.lua +++ b/apisix/plugins/sls-logger.lua @@ -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) diff --git a/t/admin/plugin-metadata.t b/t/admin/plugin-metadata.t index ac97907f4..e78ee00e8 100644 --- a/t/admin/plugin-metadata.t +++ b/t/admin/plugin-metadata.t @@ -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 @@ -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