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:
Chris Capurso
2022-11-01 09:57:23 -04:00
committed by GitHub
parent 080133efce
commit 80c2dec816
12 changed files with 142 additions and 32 deletions

View File

@@ -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")