You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "spacewander (via GitHub)" <gi...@apache.org> on 2023/02/17 07:53:58 UTC
[GitHub] [apisix] spacewander commented on a diff in pull request #8820: refactor(admin): refactor admin consumers/plugin_metadata
spacewander commented on code in PR #8820:
URL: https://github.com/apache/apisix/pull/8820#discussion_r1109404784
##########
apisix/admin/resource.lua:
##########
@@ -31,27 +31,32 @@ local mt = {
}
+local no_id_res = {"consumers", "plugin_metadata"}
+
+
function _M:check_conf(id, conf, need_id)
-- check if missing configurations
if not conf then
return nil, {error_msg = "missing configurations"}
end
-- check id if need id
- id = id or conf.id
- if need_id and not id then
- return nil, {error_msg = "missing ".. self.kind .. " id"}
- end
+ if not core.table.array_find(no_id_res, self.name) then
+ id = id or conf.id
+ if need_id and not id then
+ return nil, {error_msg = "missing ".. self.kind .. " id"}
+ end
- if not need_id and id then
- return nil, {error_msg = "wrong ".. self.kind .. " id, do not need it"}
- end
+ if not need_id and id then
+ return nil, {error_msg = "wrong ".. self.kind .. " id, do not need it"}
+ end
- if need_id and conf.id and tostring(conf.id) ~= tostring(id) then
- return nil, {error_msg = "wrong ".. self.kind .. " id"}
- end
+ if need_id and conf.id and tostring(conf.id) ~= tostring(id) then
+ return nil, {error_msg = "wrong ".. self.kind .. " id"}
+ end
- conf.id = id
+ conf.id = id
+ end
core.log.info("schema: ", core.json.delay_encode(self.schema))
Review Comment:
Look like in these resources, there is some redundant code? For example, the scheme will be logged twice.
##########
apisix/admin/resource.lua:
##########
@@ -31,27 +31,32 @@ local mt = {
}
+local no_id_res = {"consumers", "plugin_metadata"}
Review Comment:
We can define it as hash to speed up the lookup?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org