From d019802cc0424fe9e84127269948bae451c1891e Mon Sep 17 00:00:00 2001 From: hc-github-team-secure-vault-core <82990506+hc-github-team-secure-vault-core@users.noreply.github.com> Date: Thu, 7 Sep 2023 16:08:01 -0400 Subject: [PATCH] backport of commit 3130e8ba9483e10e6191d264dc97b597462bf7c1 (#22868) --- changelog/22818.txt | 3 +++ command/kv_patch.go | 5 +++++ command/kv_put.go | 5 +++++ 3 files changed, 13 insertions(+) create mode 100644 changelog/22818.txt diff --git a/changelog/22818.txt b/changelog/22818.txt new file mode 100644 index 000000000..1ef9b6440 --- /dev/null +++ b/changelog/22818.txt @@ -0,0 +1,3 @@ +```release-note:bug +cli: Fix the CLI failing to return wrapping information for KV PUT and PATCH operations when format is set to `table`. +``` diff --git a/command/kv_patch.go b/command/kv_patch.go index 3f5080d4d..d7d287c40 100644 --- a/command/kv_patch.go +++ b/command/kv_patch.go @@ -264,6 +264,11 @@ func (c *KVPatchCommand) Run(args []string) int { return PrintRawField(c.UI, secret, c.flagField) } + // If the secret is wrapped, return the wrapped response. + if secret.WrapInfo != nil && secret.WrapInfo.TTL != 0 { + return OutputSecret(c.UI, secret) + } + if Format(c.UI) == "table" { outputPath(c.UI, fullPath, "Secret Path") metadata := secret.Data diff --git a/command/kv_put.go b/command/kv_put.go index 77c0c6a11..92d68f953 100644 --- a/command/kv_put.go +++ b/command/kv_put.go @@ -219,6 +219,11 @@ func (c *KVPutCommand) Run(args []string) int { return PrintRawField(c.UI, secret, c.flagField) } + // If the secret is wrapped, return the wrapped response. + if secret.WrapInfo != nil && secret.WrapInfo.TTL != 0 { + return OutputSecret(c.UI, secret) + } + if Format(c.UI) == "table" { outputPath(c.UI, fullPath, "Secret Path") metadata := secret.Data