Skip to content

Commit

Permalink
address comments in slsa-framework#3570
Browse files Browse the repository at this point in the history
  • Loading branch information
jul-sh committed Apr 17, 2024
1 parent 8489e8a commit e280a41
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions internal/builders/docker/pkg/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ func saveOneTempFile(verbose bool, reader io.Reader, fileChannel chan tempFileRe
tmpfile, err := os.CreateTemp("", "log-*.txt")
if err != nil {
fileChannel <- tempFileResult{Err: err}
tmpfile.Close()
return
}
if _, err := tmpfile.Write(allBytes); err != nil {
Expand Down Expand Up @@ -529,13 +530,6 @@ func saveToTempFile(verbose bool, readers ...io.Reader) ([]string, error) {
}(reader)
}

// Close the channel once all goroutines have finished.
go func() {
wg.Wait()
close(printChannel)
close(fileChannel)
}()

for line := range printChannel {
fmt.Println(line)
}
Expand All @@ -548,6 +542,10 @@ func saveToTempFile(verbose bool, readers ...io.Reader) ([]string, error) {
files = append(files, result.File.Name())
}

wg.Wait()
close(printChannel)
close(fileChannel)

return files, nil
}

Expand Down

0 comments on commit e280a41

Please sign in to comment.