diff --git a/internal/argocd/helper.go b/internal/argocd/helper.go index 7f4f658..784a9c7 100644 --- a/internal/argocd/helper.go +++ b/internal/argocd/helper.go @@ -26,9 +26,19 @@ func GetApplicationChanges(ctx context.Context, repoOwner, repoName, repoDefault if err != nil { return appResList, err } - log.Debug().Msgf("Matching apps: %v", apps) + log.Debug().Msgf("Matching apps: %s", func() (s string) { + for _, app := range apps { + if s != "" { + s += ", " + app.ObjectMeta.Name + } else { + s += app.ObjectMeta.Name + } + } + return + }()) for _, app := range apps { + log.Info().Msgf("Generating application diff for ArgoCD App '%s' w/ revision %s", app.ObjectMeta.Name, revision) applicationResourceChanges, _ := GetApplicationDiff(ctx, app.ObjectMeta.Name, app.ObjectMeta.Namespace, revision) appResList = append(appResList, applicationResourceChanges) } diff --git a/internal/github/status.go b/internal/github/status.go index fdf725e..b070b97 100644 --- a/internal/github/status.go +++ b/internal/github/status.go @@ -14,6 +14,8 @@ var ( statusContextStr = "argo-diff" ) +const statusDescriptionMaxLen = 140 + const StatusPending = "pending" const StatusSuccess = "success" const StatusFailure = "failure" @@ -42,6 +44,9 @@ func Status(ctx context.Context, isPr bool, status, description, repoOwner, repo if isPr { contextStr = statusContextStr + " (pull_request)" } + if len(description) > statusDescriptionMaxLen { + description = description[:137] + "..." + } // TODO add support for AvatarURL ? // TODO add support for TargetURL ? repoStatus := &github.RepoStatus{ diff --git a/internal/process_event/code_change.go b/internal/process_event/code_change.go index 3282b43..a8e96f6 100644 --- a/internal/process_event/code_change.go +++ b/internal/process_event/code_change.go @@ -44,8 +44,8 @@ func ProcessCodeChange(eventInfo webhook.EventInfo, devMode bool, wg *sync.WaitG github.Status(ctx, isPr, github.StatusError, err.Error(), eventInfo.RepoOwner, eventInfo.RepoName, eventInfo.Sha, devMode) log.Error().Err(err).Msg("argocd.GetApplicationChanges() failed") return // we're done due to a processing error - } + log.Trace().Msgf("argocd.GetApplicationChanges() returned %d results", len(appResList)) errorCount := 0 // keep track of the number of errors changeCount := 0 // how many apps have changes @@ -60,6 +60,7 @@ func ProcessCodeChange(eventInfo webhook.EventInfo, devMode bool, wg *sync.WaitG appHealthMsg := a.ArgoApp.Status.Health.Message // appNs := a.ArgoApp.ObjectMeta.Namespance if a.WarnStr != "" { + log.Trace().Msgf("%s has WarnStr %s", appName, a.WarnStr) errorCount++ markdown += github.AppMarkdownStart(appName, "Error: "+a.WarnStr, appSyncStatus, appHealthStatus, appHealthMsg) markdown += github.AppMarkdownEnd() @@ -68,6 +69,7 @@ func ProcessCodeChange(eventInfo webhook.EventInfo, devMode bool, wg *sync.WaitG firstError = a.WarnStr } } else { + log.Trace().Msgf("%s has %d Changed Resources", appName, len(a.ChangedResources)) if len(a.ChangedResources) > 0 { changeCount++ markdown += github.AppMarkdownStart(appName, "", appSyncStatus, appHealthStatus, appHealthMsg) @@ -113,8 +115,8 @@ func ProcessCodeChange(eventInfo webhook.EventInfo, devMode bool, wg *sync.WaitG markdownStart += " compared to live state\n" markdownStart += "\n" + tStr + "\n" cMarkdown.Preamble = markdownStart - if changeCount == 0 { - // if there are no change, don't comment (but clear out any existing comments) + if changeCount == 0 && firstError == "" { + // if there are no changes or warnings, don't comment (but clear out any existing comments) _, _ = github.Comment(ctx, eventInfo.RepoOwner, eventInfo.RepoName, eventInfo.PrNum, eventInfo.Sha, []string{}) } else { _, _ = github.Comment(ctx, eventInfo.RepoOwner, eventInfo.RepoName, eventInfo.PrNum, eventInfo.Sha, cMarkdown.String())