From df149d6fea97280a3c05138a4f6249ae577fb0e4 Mon Sep 17 00:00:00 2001 From: Kuba Wieczorek Date: Wed, 6 Sep 2023 19:29:52 +0100 Subject: [PATCH 1/5] VAULT-1324 Fix the CLI failing to return wrapping information for KV PUTs and PATCHes when format is set to 'table' --- command/kv_patch.go | 5 +++++ command/kv_put.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/command/kv_patch.go b/command/kv_patch.go index ec47a01f4d5f4..9dfa125b98b5f 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 != nil && 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 8f708aade6650..fae16affbd1bf 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 != nil && 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 From e8ceb7a9278d4b7128bf4438b76d816451da411b Mon Sep 17 00:00:00 2001 From: Kuba Wieczorek Date: Thu, 7 Sep 2023 11:30:23 +0100 Subject: [PATCH 2/5] Add changelog --- changelog/22818.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog/22818.txt diff --git a/changelog/22818.txt b/changelog/22818.txt new file mode 100644 index 0000000000000..929bbede8d424 --- /dev/null +++ b/changelog/22818.txt @@ -0,0 +1,3 @@ +```release-note:bug +cli: Fix the CLI failing to return wrapping information for KV PUTs and PATCHes when format is set to `table`. +``` From eec82cc5bd4020e3a407f62826a07012168d1c0a Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Thu, 7 Sep 2023 17:22:39 +0100 Subject: [PATCH 3/5] Update changelog/22818.txt Co-authored-by: Kuba Wieczorek --- changelog/22818.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog/22818.txt b/changelog/22818.txt index 929bbede8d424..1ef9b6440b99d 100644 --- a/changelog/22818.txt +++ b/changelog/22818.txt @@ -1,3 +1,3 @@ ```release-note:bug -cli: Fix the CLI failing to return wrapping information for KV PUTs and PATCHes when format is set to `table`. +cli: Fix the CLI failing to return wrapping information for KV PUT and PATCH operations when format is set to `table`. ``` From b80c7331f2b35bd47acd0f5ee006186bc293a482 Mon Sep 17 00:00:00 2001 From: Kuba Wieczorek Date: Thu, 7 Sep 2023 20:20:30 +0100 Subject: [PATCH 4/5] Update kv_patch.go Co-authored-by: Peter Wilson --- command/kv_patch.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/command/kv_patch.go b/command/kv_patch.go index 9dfa125b98b5f..da96088d112f3 100644 --- a/command/kv_patch.go +++ b/command/kv_patch.go @@ -265,7 +265,7 @@ func (c *KVPatchCommand) Run(args []string) int { } // If the secret is wrapped, return the wrapped response. - if secret != nil && secret.WrapInfo != nil && secret.WrapInfo.TTL != 0 { + if secret.WrapInfo != nil && secret.WrapInfo.TTL != 0 { return OutputSecret(c.UI, secret) } From 989f9e906dadbdfbab230b162928efa8cb0c1908 Mon Sep 17 00:00:00 2001 From: Kuba Wieczorek Date: Thu, 7 Sep 2023 20:20:37 +0100 Subject: [PATCH 5/5] Update kv_put.go Co-authored-by: Peter Wilson --- command/kv_put.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/command/kv_put.go b/command/kv_put.go index fae16affbd1bf..d450b4415ccc0 100644 --- a/command/kv_put.go +++ b/command/kv_put.go @@ -220,7 +220,7 @@ func (c *KVPutCommand) Run(args []string) int { } // If the secret is wrapped, return the wrapped response. - if secret != nil && secret.WrapInfo != nil && secret.WrapInfo.TTL != 0 { + if secret.WrapInfo != nil && secret.WrapInfo.TTL != 0 { return OutputSecret(c.UI, secret) }