-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(admin): refactor resource routes #8611
Conversation
apisix/admin/resource.lua
Outdated
|
||
local res, err = core.etcd.get(key, not id) | ||
if not res then | ||
core.log.error("failed to get " .. self.kind .. "[", key, "] from etcd: ", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The log function will concat the string, no need to do it ourselves
apisix/admin/resource.lua
Outdated
local code, err, node_val = core.table.patch(node_value, sub_path, conf) | ||
node_value = node_val | ||
if code then | ||
return code, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look like we need to use {error_msg = err}
here?
apisix/admin/routes.lua
Outdated
|
||
|
||
return _M | ||
return resource.new("routes", "route", check_conf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think about it a bit.
Maybe it would be better to pass an opt like:
{
name = name,
kind = kind,
check_conf = check_conf
}
so people don't need to remember the order.
apisix/admin/routes.lua
Outdated
need_v3_filter = true, | ||
} | ||
|
||
|
||
local function check_conf(id, conf, need_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look like we can also share the id check logic? It is the same in other resources.
apisix/admin/routes.lua
Outdated
name = "routes", | ||
kind = "route", | ||
schema = core.schema.route, | ||
check_conf_self = check_conf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check_conf_self is not a good name. It would be better to use a valid English verb phrase as the method name.
apisix/admin/resource.lua
Outdated
|
||
|
||
function _M.new(opt) | ||
return setmetatable({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return setmetatable({ | |
return setmetatable(opt |
can be simpler
* upstream/master: (67 commits) fix: grpc-transcode plugin: fix map data population (apache#8731) change(jwt-auth): unify apisix/core/vault.lua and apisix/secret/vault.lua (apache#8660) feat: stream subsystem support consul_kv service discovery (apache#8633) fix(proxy-mirror): use with uri rewrite (apache#8718) ci: move helper script to the right dir (apache#8691) refactor(pubsub): simpify the get_cmd implementation (apache#8608) feat: stream subsystem support kubernetes service discovery (apache#8640) docs: fix deployment links (apache#8714) fix: remove backslash before slash when encoding (apache#8684) ci: kafka should register port in the zookeeper same as exposed (apache#8672) docs: fix plugin config naming (apache#8701) docs: fix code block (apache#8700) docs: rename kms to secret (apache#8697) docs: replace transparent logos with white background logos (apache#8689) fix: upgrade lua-resty-etcd to 1.10.3 (apache#8668) fix: upgrade casbin to 1.41.3 to improve performance (apache#8676) chore: make send_stream_request more clear (apache#8627) feat: stream subsystem support nacos service discovery (apache#8584) feat: stream subsystem support dns service discovery (apache#8593) refactor(admin): refactor resource routes (apache#8611) ...
Description
Fixes #8569
Checklist