From 4723a6e8bd53af7f8172f559f7dbca1b98c6cac9 Mon Sep 17 00:00:00 2001 From: "Zhefeng C." <38037704+catbro666@users.noreply.github.com> Date: Thu, 5 Sep 2024 15:57:39 +0800 Subject: [PATCH] feat(runloop): added the workspace id into the plugin config in the plugins iterator (#13602) the workspace id is needed in some cases, for example in the configure handler. https://konghq.atlassian.net/browse/FTI-6200 --- changelog/unreleased/kong/feat-plugin-conf-ws-id.yml | 3 +++ kong/runloop/plugins_iterator.lua | 1 + spec/02-integration/07-sdk/04-plugin-config_spec.lua | 1 + 3 files changed, 5 insertions(+) create mode 100644 changelog/unreleased/kong/feat-plugin-conf-ws-id.yml diff --git a/changelog/unreleased/kong/feat-plugin-conf-ws-id.yml b/changelog/unreleased/kong/feat-plugin-conf-ws-id.yml new file mode 100644 index 000000000000..06ab3da5da3d --- /dev/null +++ b/changelog/unreleased/kong/feat-plugin-conf-ws-id.yml @@ -0,0 +1,3 @@ +message: Added the workspace id into the plugin config in the plugins iterator. +type: feature +scope: Core diff --git a/kong/runloop/plugins_iterator.lua b/kong/runloop/plugins_iterator.lua index 78a6421011a6..ea0325b02d5b 100644 --- a/kong/runloop/plugins_iterator.lua +++ b/kong/runloop/plugins_iterator.lua @@ -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, diff --git a/spec/02-integration/07-sdk/04-plugin-config_spec.lua b/spec/02-integration/07-sdk/04-plugin-config_spec.lua index b56e98e73112..2a02efec0daf 100644 --- a/spec/02-integration/07-sdk/04-plugin-config_spec.lua +++ b/spec/02-integration/07-sdk/04-plugin-config_spec.lua @@ -49,5 +49,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)