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:
Jeff Mitchell
2018-06-08 13:45:47 -04:00
committed by GitHub
parent 3a2ab5a764
commit e15501e265
7 changed files with 40 additions and 12 deletions

View File

@@ -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 {