diff --git a/command/base_helpers.go b/command/base_helpers.go index f20cfebf710259204ccf72f4fcf0bec27911f166..0693abda66c061d060827d136c4cb764b89af65c 100644 --- a/command/base_helpers.go +++ b/command/base_helpers.go @@ -38,6 +38,15 @@ func sanitizePath(s string) string { return ensureNoTrailingSlash(ensureNoLeadingSlash(s)) } +// hasTrailingSpace checks to see if there is trailing space +func hasTrailingSpace(s string) bool { + x := strings.TrimSpace(s) + if x != s { + return true + } + return false +} + // ensureTrailingSlash ensures the given string has a trailing slash. func ensureTrailingSlash(s string) string { s = strings.TrimSpace(s) diff --git a/command/kv_get.go b/command/kv_get.go index 07033448187a30ebd8f83bd5cd40673babb4ae6a..a82291cd84eed65c8898ecef17ca27454010ed5a 100644 --- a/command/kv_get.go +++ b/command/kv_get.go @@ -134,7 +134,13 @@ func (c *KVGetCommand) Run(args []string) int { } else { // In this case, this arg is a path-like combination of mountPath/secretPath. // (e.g. "secret/foo") + origPath := args[0] partialPath = sanitizePath(args[0]) + + if hasTrailingSpace(origPath) { + partialPath = partialPath + " " + } + mountPath, v2, err = isKVv2(partialPath, client) if err != nil { c.UI.Error(err.Error())