Skip to content

Commit

Permalink
Don't log the value of --password if given (ko-build#458)
Browse files Browse the repository at this point in the history
  • Loading branch information
imjasonh authored Oct 1, 2021
1 parent 688ca47 commit b9cd759
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/commands/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}

0 comments on commit b9cd759

Please sign in to comment.