membphis commented on code in PR #12424:
URL: https://github.com/apache/apisix/pull/12424#discussion_r2206118895
##########
apisix/admin/standalone.lua:
##########
@@ -151,37 +172,45 @@ local function update(ctx)
end
end
+
apisix_yaml[conf_version_key] = new_conf_version
if new_conf_version == conf_version then
apisix_yaml[key] = config and config[key]
elseif items and #items > 0 then
apisix_yaml[key] = table_new(#items, 0)
- local item_schema = obj.item_schema
- local item_checker = obj.checker
+ local item_schema = resource.schema
+ local item_checker = resource.checker
local id_set = {}
- for index, item in ipairs(items) do
+ for _, item in ipairs(items) do
local item_temp = tbl_deepcopy(item)
+ local id = tostring(item.id)
local valid, err
- -- need to recover to 0-based subscript
- local err_prefix = "invalid " .. key .. " at index " .. (index
- 1) .. ", err: "
- if item_schema then
- valid, err = check_schema(obj.item_schema, item_temp)
- if not valid then
- core.log.error(err_prefix, err)
- core.response.exit(400, {error_msg = err_prefix ..
err})
- end
- end
if item_checker then
- local item_checker_key
- if item.id then
- -- credential need to check key
- item_checker_key = "/" .. key .. "/" .. item_temp.id
- end
- valid, err = item_checker(item_temp, item_checker_key)
- if not valid then
- core.log.error(err_prefix, err)
- core.response.exit(400, {error_msg = err_prefix ..
err})
+ if core.string.find(id, "/credentials/") then
Review Comment:
https://github.com/apache/apisix/blob/c4ead141b311d43dbfdd0099f975f109b4b89807/apisix/admin/standalone.lua#L189-L213
The code is a bit deep, which makes it difficult to read.
We can move this code to a separate function.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]