Set SSH verbosity based on git-sync -v value

This commit is contained in:
Tim Hockin 2024-12-12 13:21:37 -08:00
parent 97c0d585a8
commit 3d7bb94c4d
No known key found for this signature in database
1 changed files with 13 additions and 1 deletions

14
main.go
View File

@ -764,7 +764,7 @@ func main() {
// If the --repo or any submodule uses SSH, we need to know which keys. // If the --repo or any submodule uses SSH, we need to know which keys.
if err := git.SetupGitSSH(*flSSHKnownHosts, *flSSHKeyFiles, *flSSHKnownHostsFile); err != nil { if err := git.SetupGitSSH(*flSSHKnownHosts, *flSSHKeyFiles, *flSSHKnownHostsFile); err != nil {
log.Error(err, "can't set up git SSH", "keyFile", *flSSHKeyFiles, "knownHosts", *flSSHKnownHosts, "knownHostsFile", *flSSHKnownHostsFile) log.Error(err, "can't set up git SSH", "keyFiles", *flSSHKeyFiles, "useKnownHosts", *flSSHKnownHosts, "knownHostsFile", *flSSHKnownHostsFile)
os.Exit(1) os.Exit(1)
} }
@ -1912,6 +1912,18 @@ func (git *repoSync) SetupGitSSH(setupKnownHosts bool, pathsToSSHSecrets []strin
sshCmd = "ssh" sshCmd = "ssh"
} }
// We can't pre-verify that key-files exist because we call this path
// without knowing whether we actually need SSH or not, in which case the
// files may not exist and that is OK. But we can make SSH report more.
switch {
case git.log.V(9).Enabled():
sshCmd += " -vvv"
case git.log.V(7).Enabled():
sshCmd += " -vv"
case git.log.V(5).Enabled():
sshCmd += " -v"
}
for _, p := range pathsToSSHSecrets { for _, p := range pathsToSSHSecrets {
sshCmd += fmt.Sprintf(" -i %s", p) sshCmd += fmt.Sprintf(" -i %s", p)
} }