diff --git a/pkg/cmd/view-secret.go b/pkg/cmd/view-secret.go index e346281..10c6b8d 100644 --- a/pkg/cmd/view-secret.go +++ b/pkg/cmd/view-secret.go @@ -9,6 +9,7 @@ import ( "os" "os/exec" "sort" + "strings" "github.com/goccy/go-json" "github.com/spf13/cobra" @@ -167,7 +168,7 @@ func ProcessSecret(outWriter, errWriter io.Writer, secret map[string]interface{} if decodeAll { for _, k := range keys { b64d, _ := base64.StdEncoding.DecodeString(data[k].(string)) - _, _ = fmt.Fprintf(outWriter, "%s=%s\n", k, b64d) + _, _ = fmt.Fprintf(outWriter, "%s='%s'\n", k, strings.TrimSpace(string(b64d))) } } else if len(data) == 1 { for k, v := range data { diff --git a/pkg/cmd/view-secret_test.go b/pkg/cmd/view-secret_test.go index 98e8a92..1002df8 100644 --- a/pkg/cmd/view-secret_test.go +++ b/pkg/cmd/view-secret_test.go @@ -89,11 +89,9 @@ func TestProcessSecret(t *testing.T) { "view-secret test -a": { secret, []string{ - "", - "", - "TEST_CONN_STR=mongodb://myDBReader:D1fficultP%40ssw0rd@mongodb0.example.com:27017/?authSource=admin", - "TEST_PASSWORD=secret", - "TEST_PASSWORD_2=verysecret", + "TEST_CONN_STR='mongodb://myDBReader:D1fficultP%40ssw0rd@mongodb0.example.com:27017/?authSource=admin'", + "TEST_PASSWORD='secret'", + "TEST_PASSWORD_2='verysecret'", }, nil, "",