-
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
feat: add plugin config #3567
feat: add plugin config #3567
Conversation
f94bdd7
to
b3a6f79
Compare
fix apache#3532 Signed-off-by: spacewander <spacewanderlzx@gmail.com>
b3a6f79
to
4bc2eea
Compare
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.
LGTM
@@ -251,7 +251,7 @@ function _M.init(env, args) | |||
for _, dir_name in ipairs({"/routes", "/upstreams", "/services", | |||
"/plugins", "/consumers", "/node_status", | |||
"/ssl", "/global_rules", "/stream_routes", | |||
"/proto", "/plugin_metadata"}) do | |||
"/proto", "/plugin_metadata", "/plugin_configs"}) do |
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.
Is it possible to move this logic to the init_by_lua phase
in the future?
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.
After we can sync etcd data in that phase.
apisix/init.lua
Outdated
@@ -381,6 +383,18 @@ function _M.http_access_phase() | |||
core.json.delay_encode(api_ctx.matched_route, true)) | |||
|
|||
local enable_websocket = route.value.enable_websocket | |||
|
|||
if route.value.plugin_config_id then | |||
local pc = plugin_config.get(route.value.plugin_config_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.
pc
is not a good name
apisix/plugin_config.lua
Outdated
|
||
|
||
function _M.merge(route_conf, plugin_config) | ||
if route_conf.prev_plugin_config_ver ~= plugin_config.modifiedIndex then |
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.
another code style:
if route_conf.prev_plugin_config_ver == plugin_config.modifiedIndex then
return route_conf
end
...
type = "object", | ||
properties = { | ||
id = id_schema, | ||
desc = {type = "string", maxLength = 256}, |
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.
all of the desc
should be the same, declare it as a variable and just quote it
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.
Will do it in the next PR.
Signed-off-by: spacewander <spacewanderlzx@gmail.com>
apisix/admin/plugin_config.lua
Outdated
local key = "/plugin_configs/" .. id | ||
local res, err = core.etcd.delete(key) | ||
if not res then | ||
core.log.error("failed to delete global rule[", key, "]: ", 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.
Typo: should be "failed to delete plugin_config"
merged, many thx |
Fix #3532
Signed-off-by: spacewander spacewanderlzx@gmail.com
What this PR does / why we need it:
Pre-submission checklist: