-
Notifications
You must be signed in to change notification settings - Fork 3
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: allow for the retrieval of plugin schema for loaded plugins #1
Conversation
@@ -74,6 +73,114 @@ _G["load_plugin_schema"] = function(plugin_schema_string) | |||
return nil, "error initializing schema for plugin: " .. err | |||
end | |||
end | |||
|
|||
-- Remove functions from a schema definition so that |
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.
In order to remove the need for extra patching these functions were copied from kong/api/api_helpers.lua
and kong/api/routes/kong.lua
which included multiple required modules and contained c bindings.
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.
Upstream Kong is tolerant of patches. We could send a patch to move these functions into a different lua file, which this code directly consumes. Only possible if there are no changes in these functions (that can't be refactored upstream).
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.
Looks good directionally.
@@ -0,0 +1,55 @@ | |||
local typedefs = require "kong.db.schema.typedefs" | |||
local url = require "patched.url" |
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.
Stole this from the patch as well; wonder if there is something we can do which circumvents all the known modules used by Kong Gateway which use C libraries? (just thinking out loud here for 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.
Maybe, when I did all of this, my goal was to keep the patches to a minimum.
|
||
// Parse using DOM style with the map[string]interface{} | ||
// This is simpler than trying to stuff a dynamic array into a static | ||
// structure |
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.
This is fine, it is just more code and a bit harder to grok. A simple assert.JSONeq would suffice as well. No changes required. This is good as is.
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.
yeah the grok is def a negative, we can always changes it later if we find it to be cumbersome in the future.
Calling
SchemaAsJSON
afterLoadSchema
has been executed for plugins will return the plugin configuration schema. This can be used for UI generation; similar to the endpoint/schema/plugins/:name
Kong Gateway provides.TODO
SchemaAsJSON