Skip to content

Commit

Permalink
Merge pull request #7 from TDabasinskas/TDabasinskas-patch-1
Browse files Browse the repository at this point in the history
Trim trailing and leading spaces in keys and values
  • Loading branch information
ldaneliukas authored Jul 11, 2018
2 parents b8b7649 + 3ea25d4 commit 08106ff
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,15 @@ func outputToYaml(filename string, section string, encode bool, secrets []Secret
}
f.WriteString(fmt.Sprintf("---\n%s:\n", string(section)))
for _, secret := range secrets {
// Encode the secrets if needed:
var value string
// Trim spaces and encode the secrets if needed:
key := strings.Trim(secret.Key, " ")
value := strings.Trim(secret.Value, " ")
if encode {
value = base64.StdEncoding.EncodeToString([]byte(secret.Value))
} else {
value = secret.Value
}
value = base64.StdEncoding.EncodeToString([]byte(value))
}

logrus.WithField("key", secret.Key).WithField("value", "(hidden)").Infoln("Secret saved.")
f.WriteString(fmt.Sprintf(" %s: '%s'\n", secret.Key, value))
logrus.WithField("key", key).WithField("value", "(hidden)").Infoln("Secret saved.")
f.WriteString(fmt.Sprintf(" %s: '%s'\n", key, value))
}

logrus.WithField("outputPath", filename).WithField("count", len(secrets)).Infoln("Secrets successfully saved to the file.")
Expand Down

0 comments on commit 08106ff

Please sign in to comment.