Skip to content

Commit 56f49e5

Browse files
authored
fix(init) set the default workspace before using it (Kong#6206)
1 parent 88336ba commit 56f49e5

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

kong/init.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,9 @@ local function load_declarative_config(kong_config, entities, meta)
341341
end)
342342

343343
if ok then
344+
local default_ws = kong.db.workspaces:select_by_name("default")
345+
kong.default_workspace = default_ws and default_ws.id or kong.default_workspace
346+
344347
ok, err = runloop.build_plugins_iterator("init")
345348
if not ok then
346349
return nil, "error building initial plugins iterator: " .. err
@@ -350,9 +353,6 @@ local function load_declarative_config(kong_config, entities, meta)
350353
if not ok then
351354
return nil, "error building initial router: " .. err
352355
end
353-
354-
local default_ws = kong.db.workspaces:select_by_name("default")
355-
kong.default_workspace = default_ws and default_ws.id or kong.default_workspace
356356
end
357357

358358
return ok, err

kong/runloop/plugins_iterator.lua

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,11 @@ function PluginsIterator.new(version)
373373
end
374374
loaded_plugins = loaded_plugins or get_loaded_plugins()
375375

376+
local ws_id = workspaces.get_workspace_id() or kong.default_workspace
376377
local ws = {
377-
[kong.default_workspace] = new_ws_data()
378+
[ws_id] = new_ws_data()
378379
}
379380

380-
local ws_id = workspaces.get_workspace_id() or kong.default_workspace
381-
382381
local counter = 0
383382
local page_size = kong.db.plugins.pagination.page_size
384383
for plugin, err in kong.db.plugins:each(nil, GLOBAL_QUERY_OPTS) do

0 commit comments

Comments
 (0)