mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 19:17:58 +00:00
Fix writing to KVv2 root via kv put (#4726)
* Fix writing to KVv2 root via `kv put` The check that adds the API path wasn't taking into account the root, e.g. if it's mounted at `kv`, `kv` and `kv/` would end up creating an extra copy of the mount path in front, leading to paths like `kv/data/kv`. * Output warnings if they come back and fix a panic in metadata_get * Also add to metadata put/delete
This commit is contained in:
@@ -99,8 +99,13 @@ func isKVv2(path string, client *api.Client) (string, bool, error) {
|
||||
}
|
||||
|
||||
func addPrefixToVKVPath(p, mountPath, apiPrefix string) string {
|
||||
p = strings.TrimPrefix(p, mountPath)
|
||||
return path.Join(mountPath, apiPrefix, p)
|
||||
switch {
|
||||
case p == mountPath, p == strings.TrimSuffix(mountPath, "/"):
|
||||
return path.Join(mountPath, apiPrefix)
|
||||
default:
|
||||
p = strings.TrimPrefix(p, mountPath)
|
||||
return path.Join(mountPath, apiPrefix, p)
|
||||
}
|
||||
}
|
||||
|
||||
func getHeaderForMap(header string, data map[string]interface{}) string {
|
||||
|
||||
Reference in New Issue
Block a user