Skip to content

Commit

Permalink
Set SSH verbosity based on git-sync -v value
Browse files Browse the repository at this point in the history
  • Loading branch information
thockin committed Dec 12, 2024
1 parent 8b861d9 commit cffb28d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ func main() {

// If the --repo or any submodule uses SSH, we need to know which keys.
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)
}

Expand Down Expand Up @@ -1912,6 +1912,18 @@ func (git *repoSync) SetupGitSSH(setupKnownHosts bool, pathsToSSHSecrets []strin
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 {
sshCmd += fmt.Sprintf(" -i %s", p)
}
Expand Down

0 comments on commit cffb28d

Please sign in to comment.