Fix minor issues from linters
This commit is contained in:
parent
7e10cb7d13
commit
7a3c0679d5
|
|
@ -287,7 +287,7 @@ func main() {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*time.Duration(*flSyncTimeout))
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second*time.Duration(*flSyncTimeout))
|
||||||
if changed, err := syncRepo(ctx, *flRepo, *flBranch, *flRev, *flDepth, *flRoot, *flDest); err != nil {
|
if changed, err := syncRepo(ctx, *flRepo, *flBranch, *flRev, *flDepth, *flRoot, *flDest); err != nil {
|
||||||
syncDuration.WithLabelValues("error").Observe(time.Now().Sub(start).Seconds())
|
syncDuration.WithLabelValues("error").Observe(time.Since(start).Seconds())
|
||||||
syncCount.WithLabelValues("error").Inc()
|
syncCount.WithLabelValues("error").Inc()
|
||||||
if *flMaxSyncFailures != -1 && failCount >= *flMaxSyncFailures {
|
if *flMaxSyncFailures != -1 && failCount >= *flMaxSyncFailures {
|
||||||
// Exit after too many retries, maybe the error is not recoverable.
|
// Exit after too many retries, maybe the error is not recoverable.
|
||||||
|
|
@ -311,7 +311,7 @@ func main() {
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
syncDuration.WithLabelValues("success").Observe(time.Now().Sub(start).Seconds())
|
syncDuration.WithLabelValues("success").Observe(time.Since(start).Seconds())
|
||||||
syncCount.WithLabelValues("success").Inc()
|
syncCount.WithLabelValues("success").Inc()
|
||||||
|
|
||||||
if initialSync {
|
if initialSync {
|
||||||
|
|
@ -527,7 +527,7 @@ func revIsHash(ctx context.Context, rev, gitRoot string) (bool, error) {
|
||||||
func syncRepo(ctx context.Context, repo, branch, rev string, depth int, gitRoot, dest string) (bool, error) {
|
func syncRepo(ctx context.Context, repo, branch, rev string, depth int, gitRoot, dest string) (bool, error) {
|
||||||
target := path.Join(gitRoot, dest)
|
target := path.Join(gitRoot, dest)
|
||||||
gitRepoPath := path.Join(target, ".git")
|
gitRepoPath := path.Join(target, ".git")
|
||||||
hash := rev
|
var hash string
|
||||||
_, err := os.Stat(gitRepoPath)
|
_, err := os.Stat(gitRepoPath)
|
||||||
switch {
|
switch {
|
||||||
case os.IsNotExist(err):
|
case os.IsNotExist(err):
|
||||||
|
|
@ -659,7 +659,7 @@ func setupGitSSH(setupKnownHosts bool) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if setupKnownHosts {
|
if setupKnownHosts {
|
||||||
_, err := os.Stat(pathToSSHKnownHosts)
|
_, err = os.Stat(pathToSSHKnownHosts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error: could not access SSH known_hosts file: %v", err)
|
return fmt.Errorf("error: could not access SSH known_hosts file: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue