Skip to content

Commit

Permalink
Add quotes to secret values (#36)
Browse files Browse the repository at this point in the history
Co-authored-by: Jonas-Taha El Sesiy <[email protected]>
  • Loading branch information
pradeepnnv and elsesiy authored Jun 26, 2023
1 parent 6f8f58e commit c2dc2cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 2 additions & 1 deletion pkg/cmd/view-secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"os/exec"
"sort"
"strings"

"github.com/goccy/go-json"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 3 additions & 5 deletions pkg/cmd/view-secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,9 @@ func TestProcessSecret(t *testing.T) {
"view-secret test -a": {
secret,
[]string{
"",
"",
"TEST_CONN_STR=mongodb://myDBReader:D1fficultP%[email protected]:27017/?authSource=admin",
"TEST_PASSWORD=secret",
"TEST_PASSWORD_2=verysecret",
"TEST_CONN_STR='mongodb://myDBReader:D1fficultP%[email protected]:27017/?authSource=admin'",
"TEST_PASSWORD='secret'",
"TEST_PASSWORD_2='verysecret'",
},
nil,
"",
Expand Down

0 comments on commit c2dc2cd

Please sign in to comment.