I am migrating from Kong 2.8.0 to 3.0.0. I have a few custom plugins which are giving me trouble while migrating.
Once i start migration I am getting this error:
[error] 1#0: init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:560: error loading plugin schemas: on plugin 'file-log-extended': [postgres] 2 schema violations (fields: expected an array; name: field required for entity check)
stack traceback:
[C]: in function 'assert'
/usr/local/share/lua/5.1/kong/init.lua:560: in function 'init'
init_by_lua:3: in main chunk
So, the problem to me seems related to the schema.lua :
local typedefs = require "kong.db.schema.typedefs"
local pl_utils = require "pl.utils"
return {
fields = {
path = { required = true, type = "string"},
log_bodies = { type = "boolean", default = true }
}
}
What I've done is changing the schema to:
...
return {
fields = {{
config = {
type = "record",
fields = {
path = { required = true, type = "string"},
log_bodies = { type = "boolean", default = true }
}
}
}}
}
But now when I start Kong I get the following error:
[error] 1#0: init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:543: error
loading plugin schemas: on plugin 'file-log-extended': failed converting legacy schema for file-log-extended: unknown legacy field attribute: "config"
stack traceback:
[C]: in function 'assert'
/usr/local/share/lua/5.1/kong/init.lua:543: in function 'init'
init_by_lua:3: in main chunk
Can someone help me understand why I can't migrate properly this plugin?
Thanks
Actually the format was incorrect. This version is accepted.
return {
name="file-log-extended",
fields = {
{
-- this plugin will only be applied to Services or Routes
consumer = typedefs.no_consumer
},
{
config = {
type = "record",
fields = {
-- Describe your plugin's configuration's schema here.
{
path = {
required = true,
type = "string"
}
},
{
log_bodies = {
type = "boolean",
default = true
}
}
}
}
}
}
}