Skip to content

Commit

Permalink
feat(runloop): added the workspace id into the plugin config in the p…
Browse files Browse the repository at this point in the history
…lugins iterator

the workspace id is needed in some cases, for example in the configure handler.

https://konghq.atlassian.net/browse/FTI-6200
  • Loading branch information
catbro666 committed Sep 2, 2024
1 parent d10408c commit 4bdbdff
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions changelog/unreleased/kong/feat-plugin-conf-ws-id.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
message: Added the workspace id into the plugin config in the plugins iterator.
type: feature
scope: Core
1 change: 1 addition & 0 deletions kong/runloop/plugins_iterator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ local function get_plugin_config(plugin, name, ws_id)
cfg.consumer_id = plugin.consumer and plugin.consumer.id
cfg.plugin_instance_name = plugin.instance_name
cfg.__plugin_id = plugin.id
cfg.__ws_id = ws_id

local key = kong.db.plugins:cache_key(name,
cfg.route_id,
Expand Down
2 changes: 2 additions & 0 deletions spec/02-integration/07-sdk/04-plugin-config_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local cjson = require "cjson"

describe("Plugin configuration", function()
local proxy_client
local default_ws_id = workspaces.get_workspace().id

lazy_setup(function()
local bp = helpers.get_db_utils(nil, {
Expand Down Expand Up @@ -49,5 +50,6 @@ describe("Plugin configuration", function()
local body = assert.status(200, res)
local json = cjson.decode(body)
assert.equal("test", json.plugin_instance_name)
assert.equal(kong.default_workspace, json.__ws_id)
end)
end)

0 comments on commit 4bdbdff

Please sign in to comment.