From 135dc205627ed5876032d4b27a481381292e1a04 Mon Sep 17 00:00:00 2001 From: Richard Gomez Date: Fri, 9 Feb 2024 12:28:46 -0500 Subject: [PATCH] refactor(github): change scanErrs.String output --- pkg/sources/errors.go | 14 ++++++++++++-- pkg/sources/github/github.go | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/pkg/sources/errors.go b/pkg/sources/errors.go index 3ec62a74d6af..123241b34356 100644 --- a/pkg/sources/errors.go +++ b/pkg/sources/errors.go @@ -2,7 +2,7 @@ package sources import ( "errors" - "fmt" + "strings" "sync" ) @@ -35,7 +35,17 @@ func (s *ScanErrors) Count() uint64 { func (s *ScanErrors) String() string { s.mu.RLock() defer s.mu.RUnlock() - return fmt.Sprintf("%v", s.errors) + + var sb strings.Builder + sb.WriteString("[") + for i, err := range s.errors { + sb.WriteString(`"` + err.Error() + `"`) + if i < len(s.errors)-1 { + sb.WriteString(", ") + } + } + sb.WriteString("]") + return sb.String() } func (s *ScanErrors) Errors() error { diff --git a/pkg/sources/github/github.go b/pkg/sources/github/github.go index 7972e562d00e..9ad9e2099d0c 100644 --- a/pkg/sources/github/github.go +++ b/pkg/sources/github/github.go @@ -748,7 +748,7 @@ func (s *Source) scan(ctx context.Context, installationClient *github.Client, ch _ = s.jobPool.Wait() if scanErrs.Count() > 0 { - s.log.V(0).Info("failed to scan some repositories", "error_count", scanErrs.Count(), "errors", scanErrs) + s.log.V(0).Info("failed to scan some repositories", "error_count", scanErrs.Count(), "errors", scanErrs.String()) } s.SetProgressComplete(len(s.repos), len(s.repos), "Completed GitHub scan", "")