Don't log the value of --password if given (#458)

This commit is contained in:
Jason Hall
2021-10-01 14:19:26 -04:00
committed by GitHub
parent 688ca47675
commit b9cd759f25
+12 -1
View File
@@ -90,7 +90,7 @@ func addCreate(topLevel *cobra.Command) {
// remaining flags passed after '--'.
argv := []string{"apply", "-f", "-"}
if kflags := kf.Values(); len(kflags) != 0 {
skflags := strings.Join(kflags, " ")
skflags := strings.Join(stripPassword(kflags), " ")
log.Printf(kubectlFlagsWarningTemplate,
"create", skflags,
"create", skflags)
@@ -147,3 +147,14 @@ func addCreate(topLevel *cobra.Command) {
topLevel.AddCommand(create)
}
func stripPassword(flags []string) []string {
cp := make([]string, len(flags))
for _, f := range flags {
if strings.HasPrefix(f, "--password=") {
f = "--password=REDACTED"
}
cp = append(cp, f)
}
return cp
}