Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backport -> release/3.7.x] fix(vault): let vault entity cache key not containing workspace id #13669

Merged
merged 1 commit into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/unreleased/kong/fix-vault-cache-workspace-id.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
message: |
**Vault**: Fixed an issue where updating a vault entity in a non-default workspace will not take effect.
type: bugfix
scope: Core
10 changes: 10 additions & 0 deletions kong/db/dao/vaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,14 @@ function Vaults:load_vault_schemas(vault_set)
end


function Vaults:cache_key(prefix)
if type(prefix) == "table" then
prefix = prefix.prefix
end

-- Always return the cache_key without a workspace because prefix is unique across workspaces
return "vaults:" .. prefix .. ":::::"
end


return Vaults
5 changes: 5 additions & 0 deletions spec/02-integration/13-vaults/01-vault_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -175,5 +175,10 @@ for _, strategy in helpers.each_strategy() do
assert.is_equal("{vault://unknown/missing-key}", certificate.key_alt)
assert.is_nil(certificate["$refs"])
end)

it("generate correct cache key", function ()
local cache_key = db.vaults:cache_key("test")
assert.equal("vaults:test:::::", cache_key)
end)
end)
end
Loading