bzp2010 commented on code in PR #12424:
URL: https://github.com/apache/apisix/pull/12424#discussion_r2208089852
##########
apisix/admin/consumer_group.lua:
##########
@@ -23,7 +23,7 @@ local tostring = tostring
local ipairs = ipairs
-local function check_conf(id, conf, need_id, schema)
+local function check_conf(id, conf, need_id, schema, secret_type,
skip_references_check)
Review Comment:
What is the relevance of secret type to consumer group? In fact, according
to these code changes, it has nothing to do with any code other than the secret.
Normally, we wouldn't write something like `fu(nil, true)` in codes. A
required field should not come after an optional field.
Most functions don't care about the value of `secret_type`, and more
importantly, we can't accept an infinite rise in the number of input arguments
to this function. I would suggest using a table directly as an input parameter,
so that you can be completely unconcerned about which fields are not needed.
```lua
local function fn1(i1, i2, i3, opts)
if opts.skip_references_check then
-- do something
end
end
local function fn2(i1, i2, i3, opts)
if opts.secret_type == "xx" then
-- do something
end
end
```
##########
apisix/admin/stream_routes.lua:
##########
@@ -72,7 +72,12 @@ return resource.new({
name = "stream_routes",
kind = "stream route",
schema = core.schema.stream_route,
- checker = check_conf,
+ checker = function (id, conf, need_id, schema)
+ return check_conf(id, conf, need_id, schema, false)
+ end,
+ standalone_checker = function (id, conf, need_id, schema)
+ return check_conf(id, conf, need_id, schema, true)
+ end,
Review Comment:
Why is `standalone_checker` added only to this resource type and not to the
others?
--
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]