Skip to content

Commit

Permalink
Update planpreview comment format (#4101)
Browse files Browse the repository at this point in the history
* Update planpreview comment format

* fixup
  • Loading branch information
knanao committed Jan 6, 2023
1 parent c107c74 commit b54d488
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions tool/actions-plan-preview/planpreview.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,13 @@ func makeCommentBody(event *githubEvent, r *PlanPreviewResult) string {
b.WriteString(fmt.Sprintf(hasChangeTitleFormat, event.HeadCommit, len(r.Applications)))

changedApps, pipelineApps, quickSyncApps := groupApplicationResults(r.Applications)
if len(changedApps)+len(pipelineApps)+len(quickSyncApps) > 0 {
b.WriteString("\n## Plans\n\n")
}

var detailLen int

for _, app := range changedApps {
fmt.Fprintf(&b, "\n## %s\n", makeTitleText(&app.ApplicationInfo))
fmt.Fprintf(&b, "\n### %s\n", makeTitleText(&app.ApplicationInfo))
fmt.Fprintf(&b, "Sync strategy: %s\n", app.SyncStrategy)
fmt.Fprintf(&b, "Summary: %s\n\n", app.PlanSummary)

Expand Down Expand Up @@ -211,7 +213,7 @@ func makeCommentBody(event *githubEvent, r *PlanPreviewResult) string {
}

if len(pipelineApps)+len(quickSyncApps) > 0 {
b.WriteString("\n## No resource changes were detected but the following apps will also be triggered\n")
b.WriteString("\n### No resource changes were detected but the following apps will also be triggered\n")

if len(pipelineApps) > 0 {
b.WriteString("\n###### `PIPELINE`\n")
Expand All @@ -232,13 +234,13 @@ func makeCommentBody(event *githubEvent, r *PlanPreviewResult) string {
return b.String()
}

fmt.Fprintf(&b, "\n---\n\n## NOTE\n\n")
fmt.Fprintf(&b, "\n## NOTE\n\n")

if len(r.FailureApplications) > 0 {
fmt.Fprintf(&b, "**An error occurred while building plan-preview for the following applications**\n")

for _, app := range r.FailureApplications {
fmt.Fprintf(&b, "\n## %s\n", makeTitleText(&app.ApplicationInfo))
fmt.Fprintf(&b, "\n### %s\n", makeTitleText(&app.ApplicationInfo))
fmt.Fprintf(&b, "Reason: %s\n\n", app.Reason)

var lang = "diff"
Expand All @@ -256,7 +258,7 @@ func makeCommentBody(event *githubEvent, r *PlanPreviewResult) string {
fmt.Fprintf(&b, "**An error occurred while building plan-preview for applications of the following Pipeds**\n")

for _, piped := range r.FailurePipeds {
fmt.Fprintf(&b, "\n## piped: [%s](%s)\n", piped.PipedID, piped.PipedURL)
fmt.Fprintf(&b, "\n### piped: [%s](%s)\n", piped.PipedID, piped.PipedURL)
fmt.Fprintf(&b, "Reason: %s\n\n", piped.Reason)
}
}
Expand Down

0 comments on commit b54d488

Please sign in to comment.