diff --git a/kong/constants.lua b/kong/constants.lua index ee5fb1534ac..7a05f24cf53 100644 --- a/kong/constants.lua +++ b/kong/constants.lua @@ -206,6 +206,8 @@ local constants = { PROTOCOLS = protocols, PROTOCOLS_WITH_SUBSYSTEM = protocols_with_subsystem, + DECLARATIVE_DEFAULT_WORKSPACE_ID = "0dc6f45b-8f8d-40d2-a504-473544ee190b", + DECLARATIVE_LOAD_KEY = "declarative_config:loaded", DECLARATIVE_HASH_KEY = "declarative_config:hash", DECLARATIVE_DEFAULT_WORKSPACE_KEY = "declarative_config:default_workspace", diff --git a/kong/db/dao/workspaces.lua b/kong/db/dao/workspaces.lua index a0a40c43e8e..1725d760d5c 100644 --- a/kong/db/dao/workspaces.lua +++ b/kong/db/dao/workspaces.lua @@ -5,6 +5,7 @@ local constants = require("kong.constants") local lmdb = require("resty.lmdb") +local DECLARATIVE_DEFAULT_WORKSPACE_ID = constants.DECLARATIVE_DEFAULT_WORKSPACE_ID local DECLARATIVE_DEFAULT_WORKSPACE_KEY = constants.DECLARATIVE_DEFAULT_WORKSPACE_KEY @@ -28,8 +29,8 @@ end function Workspaces:select_by_name(key, options) if kong.configuration.database == "off" and key == "default" then -- it should be a table, not a single string - local id = lmdb.get(DECLARATIVE_DEFAULT_WORKSPACE_KEY) - return id and { id = lmdb.get(DECLARATIVE_DEFAULT_WORKSPACE_KEY), } or nil + local id = lmdb.get(DECLARATIVE_DEFAULT_WORKSPACE_KEY) or DECLARATIVE_DEFAULT_WORKSPACE_ID + return { id = lmdb.get(DECLARATIVE_DEFAULT_WORKSPACE_KEY), } end return self.super.select_by_name(self, key, options) diff --git a/kong/db/schema/others/declarative_config.lua b/kong/db/schema/others/declarative_config.lua index 2310010c474..6d7c47e4d50 100644 --- a/kong/db/schema/others/declarative_config.lua +++ b/kong/db/schema/others/declarative_config.lua @@ -743,7 +743,7 @@ end local function insert_default_workspace_if_not_given(_, entities) - local default_workspace = find_default_ws(entities) or "0dc6f45b-8f8d-40d2-a504-473544ee190b" + local default_workspace = find_default_ws(entities) or constants.DECLARATIVE_DEFAULT_WORKSPACE_ID if not entities.workspaces then entities.workspaces = {}