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

support Vault KV subkeys to avoid consul-template adding /data/ to the path #2016

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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: 2 additions & 2 deletions dependency/vault_read.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,9 +212,9 @@ func shimKVv2Path(rawPath, mountPath, clientNamespace string) string {
// Trim (mount path - client namespace) from the raw path
p := strings.TrimPrefix(rawPath, rawPathNsAndMountPath)

// Only add /data/ prefix to the path if neither /data/ or /metadata/ are
// Only add /data/ prefix to the path if neither /data/, or /metadata/ or /subkeys/ are
// present.
if strings.HasPrefix(p, "data/") || strings.HasPrefix(p, "metadata/") {
if strings.HasPrefix(p, "data/") || strings.HasPrefix(p, "metadata/") || strings.HasPrefix(p, "subkeys/") {
return rawPath
}

Expand Down
17 changes: 16 additions & 1 deletion dependency/vault_read_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,22 @@ func TestShimKVv2Path(t *testing.T) {
"secret/",
"secret/data/foometadata/foo/bar",
"",
}, {
},
{
"prefix not added to subkeys",
"/secret/subkeys/foo",
"secret/",
"secret/subkeys/foo",
"",
},
{
"prefix added with subkeys* in subpath",
"/secret/subkeysfoo/foo/bar",
"secret/",
"secret/data/subkeysfoo/foo/bar",
"",
},
{
"prefix added to mount path",
"secret/",
"secret/",
Expand Down
Loading