From 4df049664cb053300fb6fb3435eaab215b449369 Mon Sep 17 00:00:00 2001 From: Kuba Wieczorek Date: Thu, 7 Sep 2023 19:43:57 +0000 Subject: [PATCH] backport of commit 3130e8ba9483e10e6191d264dc97b597462bf7c1 --- 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 000000000000..1ef9b6440b99 --- /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 ec47a01f4d5f..da96088d112f 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 8f708aade665..d450b4415ccc 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