From ea3995bb4cc50354856fe6c037ddb0303dd854e4 Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Sat, 8 Jun 2024 19:36:42 -0700 Subject: [PATCH 1/3] Don't log hidden flags --- main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.go b/main.go index bd7988526..916a4cb5c 100644 --- a/main.go +++ b/main.go @@ -968,6 +968,10 @@ func redactURL(urlstr string) string { func logSafeFlags(v int) []string { ret := []string{} pflag.VisitAll(func(fl *pflag.Flag) { + // Don't log hidden flags + if fl.Hidden { + return + } // Don't log unchanged values if !fl.Changed && v <= 3 { return From 8491563d1b7854718d5ab364f56aa7d12d2d5eb1 Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Sat, 8 Jun 2024 19:56:37 -0700 Subject: [PATCH 2/3] Log the binary version --- main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/main.go b/main.go index 916a4cb5c..72a6e5288 100644 --- a/main.go +++ b/main.go @@ -544,6 +544,7 @@ func main() { // log.V(0).Info("starting up", + "version", version.VERSION, "pid", os.Getpid(), "uid", os.Getuid(), "gid", os.Getgid(), From bf50373be1e38cdc0aba1b1ae360b0167ecf4902 Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Sat, 8 Jun 2024 23:01:17 -0700 Subject: [PATCH 3/3] Log the git version --- main.go | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/main.go b/main.go index 72a6e5288..f2dfa58dd 100644 --- a/main.go +++ b/main.go @@ -622,18 +622,6 @@ func main() { } } - // Don't pollute the user's .gitconfig if this is being run directly. - if f, err := os.CreateTemp("", "git-sync.gitconfig.*"); err != nil { - log.Error(err, "ERROR: can't create gitconfig file") - os.Exit(1) - } else { - gitConfig := f.Name() - f.Close() - os.Setenv("GIT_CONFIG_GLOBAL", gitConfig) - os.Setenv("GIT_CONFIG_NOSYSTEM", "true") - log.V(2).Info("created private gitconfig file", "path", gitConfig) - } - // Capture the various git parameters. git := &repoSync{ cmd: *flGitCmd, @@ -655,6 +643,26 @@ func main() { // no long-running operations like `git fetch`, so hopefully 30 seconds will be enough. ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + // Log the git version. + if ver, _, err := cmdRunner.Run(ctx, "", nil, *flGitCmd, "version"); err != nil { + log.Error(err, "can't get git version") + os.Exit(1) + } else { + log.V(0).Info("git version", "version", ver) + } + + // Don't pollute the user's .gitconfig if this is being run directly. + if f, err := os.CreateTemp("", "git-sync.gitconfig.*"); err != nil { + log.Error(err, "ERROR: can't create gitconfig file") + os.Exit(1) + } else { + gitConfig := f.Name() + f.Close() + os.Setenv("GIT_CONFIG_GLOBAL", gitConfig) + os.Setenv("GIT_CONFIG_NOSYSTEM", "true") + log.V(2).Info("created private gitconfig file", "path", gitConfig) + } + // Set various configs we want, but users might override. if err := git.SetupDefaultGitConfigs(ctx); err != nil { log.Error(err, "can't set default git configs")