complone commented on issue #5800:
URL: https://github.com/apache/apisix/issues/5800#issuecomment-1112848299
@tzssangglass
I understand that I should define the relevant plugin_config_id in
```shcema_def.lua```, and then set the relevant plugin_config_id in
```consumer.lua#plugin_consumer```
shcema_def.lua
```
_M.consumer = {
type = "object",
properties = {
username = {
type = "string", minLength = 1, maxLength =
rule_name_def.maxLength,
pattern = [[^[a-zA-Z0-9_]+$]]
},
> id = id_schema,
plugins = plugins_schema,
labels = labels_def,
create_time = timestamp_def,
update_time = timestamp_def,
desc = desc_def,
},
required = {"username"},
}
```
consumer.lua
```
local function plugin_consumer()
local plugins = {}
if consumers.values == nil then
return plugins
end
for _, consumer in ipairs(consumers.values) do
if type(consumer) ~= "table" then
goto CONTINUE
end
for name, config in pairs(consumer.value.plugins or {}) do
local plugin_obj = plugin.get(name)
if plugin_obj and plugin_obj.type == "auth" then
if not plugins[name] then
plugins[name] = {
nodes = {},
conf_version = consumers.conf_version
}
end
local new_consumer = core.table.clone(consumer.value)
-- Note: the id here is the key of consumer data, which
-- is 'username' field in admin
> new_consumer.id = consumer.value.id
new_consumer.consumer_name = new_consumer.id
new_consumer.auth_conf = config
core.log.info("consumer:",
core.json.delay_encode(new_consumer))
core.table.insert(plugins[name].nodes, new_consumer)
end
end
::CONTINUE::
end
return plugins
end
```
--
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]