Merge pull request #581 from thockin/v3_log_creds_md5

v3: log.V(9) md5sums of credentials
This commit is contained in:
Kubernetes Prow Robot 2022-07-14 10:04:57 -07:00 committed by GitHub
commit 2fdab7789a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 0 deletions

View File

@ -20,6 +20,7 @@ package main // import "k8s.io/git-sync/cmd/git-sync"
import (
"context"
"crypto/md5"
"flag"
"fmt"
"io"
@ -1090,8 +1091,15 @@ func getRevs(ctx context.Context, repo, localDir, branch, rev string) (string, s
return local, remote, nil
}
func md5sum(s string) string {
h := md5.New()
io.WriteString(h, s)
return fmt.Sprintf("%x", h.Sum(nil))
}
func storeGitCredentials(ctx context.Context, username, password, gitURL string) error {
log.V(3).Info("storing git credentials")
log.V(9).Info("md5 of credentials", "username", md5sum(username), "password", md5sum(password))
creds := fmt.Sprintf("url=%v\nusername=%v\npassword=%v\n", gitURL, username, password)
_, err := cmdRunner.RunWithStdin(ctx, "", nil, creds, *flGitCmd, "credential", "approve")