From 69e0ef59af4b978dc41587689b2919421573111e Mon Sep 17 00:00:00 2001 From: Joseph Lombrozo Date: Wed, 30 Aug 2023 18:42:26 -0500 Subject: [PATCH] sort the names of the apps (#57) without this, the comments bounce around for large MRs --- pkg/vcs_clients/message.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/pkg/vcs_clients/message.go b/pkg/vcs_clients/message.go index e8b824be..4d0e7123 100644 --- a/pkg/vcs_clients/message.go +++ b/pkg/vcs_clients/message.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "regexp" + "sort" "strings" "sync" @@ -15,7 +16,7 @@ const ( appFormat = `
## ArgoCD Application Checks:` + "`%s` %s" + - ` + ` %s
@@ -77,10 +78,17 @@ func (m *Message) buildComment(ctx context.Context) string { _, span := otel.Tracer("Kubechecks").Start(ctx, "buildComment") defer span.End() + var names []string + for _, name := range m.Apps { + names = append(names, name) + } + sort.Strings(names) + var sb strings.Builder fmt.Fprintf(&sb, "# Kubechecks Report\n") // m.Msg = fmt.Sprintf("%s \n\n---\n\n%s", m.Msg, msg) - for app, msg := range m.Apps { + for _, name := range names { + msg := m.Apps[name] appEmoji := pkg.PassEmoji() // Test the message for failures, since we'll be showing this at the top @@ -88,7 +96,7 @@ func (m *Message) buildComment(ctx context.Context) string { appEmoji = pkg.FailedEmoji() } - fmt.Fprintf(&sb, appFormat, app, appEmoji, msg) + fmt.Fprintf(&sb, appFormat, name, appEmoji, msg) } return sb.String() }