jiangfucheng commented on code in PR #9044:
URL: https://github.com/apache/apisix/pull/9044#discussion_r1135562822
##########
apisix/admin/upstreams.lua:
##########
@@ -33,31 +38,102 @@ local function check_conf(id, conf, need_id)
return true
end
+local function up_id_in_plugins(plugins, up_id)
+ if plugins and plugins["traffic-split"]
+ and plugins["traffic-split"].rules then
-local function delete_checker(id)
- local routes, routes_ver = get_routes()
- if routes_ver and routes then
- for _, route in ipairs(routes) do
- if type(route) == "table" and route.value
- and route.value.upstream_id
- and tostring(route.value.upstream_id) == id then
- return 400, {error_msg = "can not delete this upstream,"
- .. " route [" .. route.value.id
- .. "] is still using it now"}
+ for _, rule in ipairs(plugins["traffic-split"].rules) do
+ local plugin_upstreams = rule.weighted_upstreams
+
+ for _, plugin_upstream in ipairs(plugin_upstreams) do
+ if plugin_upstream.upstream_id
+ and tostring(plugin_upstream.upstream_id) == up_id then
+
+ return true
+ end
+ end
+ end
+
+ return false
+ end
+end
+
+local function check_resources_reference(resources, resources_ver, up_id,
+ only_check_plugin, resources_name)
+
+ if resources and resources_ver then
+ for _, resource in ipairs(resources) do
+ if type(resource) == "table" and resource.value then
+ if up_id_in_plugins(resource.value.plugins, up_id) then
+
Review Comment:
Fixed. Do you have any good tools for automated detection of code
formatting errors? I use vscode as my IDE, but haven't found a suitable plugin
to do this.
--
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]