mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-29 17:52:32 +00:00
Fix kv -mount flag error when mount and secret path are the same (#17679)
* fix mount flag behavior for kv subcommands * fix mount flag behavior for kv metadata subcommands * add tests * add changelog entry
This commit is contained in:
@@ -113,7 +113,7 @@ func (c *KVGetCommand) Run(args []string) int {
|
||||
|
||||
// If true, we're working with "-mount=secret foo" syntax.
|
||||
// If false, we're using "secret/foo" syntax.
|
||||
mountFlagSyntax := (c.flagMount != "")
|
||||
mountFlagSyntax := c.flagMount != ""
|
||||
|
||||
var (
|
||||
mountPath string
|
||||
@@ -126,12 +126,15 @@ func (c *KVGetCommand) Run(args []string) int {
|
||||
// Parse the paths and grab the KV version
|
||||
if mountFlagSyntax {
|
||||
// In this case, this arg is the secret path (e.g. "foo").
|
||||
mountPath = sanitizePath(c.flagMount)
|
||||
_, v2, err = isKVv2(mountPath, client)
|
||||
mountPath, v2, err = isKVv2(sanitizePath(c.flagMount), client)
|
||||
if err != nil {
|
||||
c.UI.Error(err.Error())
|
||||
return 2
|
||||
}
|
||||
|
||||
if v2 {
|
||||
partialPath = path.Join(mountPath, partialPath)
|
||||
}
|
||||
} else {
|
||||
// In this case, this arg is a path-like combination of mountPath/secretPath.
|
||||
// (e.g. "secret/foo")
|
||||
|
||||
Reference in New Issue
Block a user