diff --git a/hack/tools/release/notes.go b/hack/tools/release/notes.go index 3ad9e77741fd..2e825caf2786 100644 --- a/hack/tools/release/notes.go +++ b/hack/tools/release/notes.go @@ -225,16 +225,16 @@ func run() int { } } - results := make(chan processCommitResult) - jobs := make(chan *commit) + results := make(chan releaseNoteEntryResult) + commitCh := make(chan *commit) var wg sync.WaitGroup wg.Add(*numWorkers) for i := 0; i < *numWorkers; i++ { go func() { - for commit := range jobs { - processed := processCommitResult{} - processed.prEntry, processed.err = generateNotesPREntry(commit) + for commit := range commitCh { + processed := releaseNoteEntryResult{} + processed.prEntry, processed.err = generateReleaseNoteEntry(commit) results <- processed } wg.Done() @@ -243,9 +243,9 @@ func run() int { go func() { for _, c := range commits { - jobs <- c + commitCh <- c } - close(jobs) + close(commitCh) }() go func() { @@ -345,19 +345,23 @@ func commandExists(cmd string) bool { return err == nil } -type processCommitResult struct { - prEntry *prEntry +// releaseNoteEntryResult is the result of processing a PR to create a release note item. +// Used to aggregate the line item and error when processing concurrently. +type releaseNoteEntryResult struct { + prEntry *releaseNoteEntry err error } -type prEntry struct { +// releaseNoteEntry represents a line item in the release notes. +type releaseNoteEntry struct { title string section string prNumber string } -func generateNotesPREntry(c *commit) (*prEntry, error) { - entry := &prEntry{} +// generateReleaseNoteEntry processes a commit into a PR line item for the release notes. +func generateReleaseNoteEntry(c *commit) (*releaseNoteEntry, error) { + entry := &releaseNoteEntry{} entry.title = trimTitle(c.body) var fork string prefix, err := getAreaLabel(c.merge)