From 35493cfee43324a571c924aff501cf018ac73d81 Mon Sep 17 00:00:00 2001 From: akshya96 <87045294+akshya96@users.noreply.github.com> Date: Thu, 13 Oct 2022 15:15:01 -0700 Subject: [PATCH] vault operator init -output-curl-string bug (#17514) * fixing -output-curl-string bug * add changelog * fix for -output-policy * adding comment for -output-policy --- changelog/17514.txt | 3 +++ command/operator_init.go | 12 ++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 changelog/17514.txt diff --git a/changelog/17514.txt b/changelog/17514.txt new file mode 100644 index 0000000000..215ea83295 --- /dev/null +++ b/changelog/17514.txt @@ -0,0 +1,3 @@ +```release-note:bug +core: Fix vault operator init command to show the right curl string with -output-curl-string and right policy hcl with -output-policy +``` \ No newline at end of file diff --git a/command/operator_init.go b/command/operator_init.go index 6d67dcd9b6..3b0dfe3de2 100644 --- a/command/operator_init.go +++ b/command/operator_init.go @@ -237,6 +237,15 @@ func (c *OperatorInitCommand) Run(args []string) int { return 2 } + // -output-curl string returns curl command for seal status + // setting this to false and then setting actual value after reading seal status + currentOutputCurlString := client.OutputCurlString() + client.SetOutputCurlString(false) + // -output-policy string returns minimum required policy HCL for seal status + // setting this to false and then setting actual value after reading seal status + outputPolicy := client.OutputPolicy() + client.SetOutputPolicy(false) + // Set defaults based on use of auto unseal seal sealInfo, err := client.Sys().SealStatus() if err != nil { @@ -244,6 +253,9 @@ func (c *OperatorInitCommand) Run(args []string) int { return 2 } + client.SetOutputCurlString(currentOutputCurlString) + client.SetOutputPolicy(outputPolicy) + switch sealInfo.RecoverySeal { case true: if c.flagRecoveryShares == 0 {