-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wasm): add wasm plugin interface (#13843)
- Loading branch information
Showing
15 changed files
with
774 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
message: "**proxy-wasm**: Added support for Wasm filters to be configured via the /plugins admin API" | ||
type: feature | ||
scope: Core |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
local constants = require "kong.constants" | ||
local json_schema = require "kong.db.schema.json" | ||
local wasm = require "kong.runloop.wasm" | ||
|
||
|
||
---@class kong.db.schema.entities.wasm_filter : table | ||
--- | ||
---@field name string | ||
---@field enabled boolean | ||
---@field config any|nil | ||
|
||
|
||
local filter_config_schema = { | ||
parent_subschema_key = "name", | ||
namespace = constants.SCHEMA_NAMESPACES.PROXY_WASM_FILTERS, | ||
optional = true, | ||
default = { | ||
["$schema"] = json_schema.DRAFT_4, | ||
-- filters with no user-defined JSON schema may accept an optional | ||
-- config, but only as a string | ||
type = { "string", "null" }, | ||
}, | ||
} | ||
|
||
|
||
-- FIXME: this is clunky and error-prone because a harmless refactor might | ||
-- affect whether this file is require()-ed before or after `kong.configuration` | ||
-- is initialized | ||
if kong and kong.configuration and kong.configuration.role == "data_plane" then | ||
-- data plane nodes are not guaranteed to have access to filter metadata, so | ||
-- they will use a JSON schema that permits all data types | ||
-- | ||
-- this branch can be removed if we decide to turn off entity validation in | ||
-- the data plane altogether | ||
filter_config_schema = { | ||
inline = { | ||
["$schema"] = json_schema.DRAFT_4, | ||
type = { "array", "boolean", "integer", "null", "number", "object", "string" }, | ||
}, | ||
} | ||
end | ||
|
||
|
||
return { | ||
type = "record", | ||
fields = { | ||
{ name = { type = "string", required = true, one_of = wasm.filter_names, | ||
err = "no such filter", }, }, | ||
{ enabled = { type = "boolean", default = true, required = true, }, }, | ||
|
||
{ config = { | ||
type = "json", | ||
required = false, | ||
json_schema = filter_config_schema, | ||
}, | ||
}, | ||
|
||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
4059a31
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.
Bazel Build
Docker image available
kong/kong:4059a31a5869433f13d3f4f4e50f91e7cf20c3e2
Artifacts available https://github.com/Kong/kong/actions/runs/11863132691