From 96f43e065ef7ab80fe42002b7ece90bf57b4bc2a Mon Sep 17 00:00:00 2001 From: Juliette Pretot Date: Mon, 15 Apr 2024 23:51:35 +0000 Subject: [PATCH] rm-double-loop Signed-off-by: Juliette Pretot --- internal/builders/docker/pkg/builder.go | 35 +++++++++++-------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/internal/builders/docker/pkg/builder.go b/internal/builders/docker/pkg/builder.go index dff9c93c68..1da5726de1 100644 --- a/internal/builders/docker/pkg/builder.go +++ b/internal/builders/docker/pkg/builder.go @@ -482,30 +482,27 @@ func saveToTempFile(verbose bool, readers ...io.Reader) ([]string, error) { var files []string for _, reader := range readers { var allBytes []byte + if verbose { + fmt.Print("\n\n>>>>>>>>>>>>>> output from command <<<<<<<<<<<<<<\n") + } - for _, reader := range readers { - if verbose { - fmt.Print("\n\n>>>>>>>>>>>>>> output from command <<<<<<<<<<<<<<\n") - } - - scanner := bufio.NewScanner(reader) - for scanner.Scan() { - bytes := scanner.Bytes() - allBytes = append(allBytes, bytes...) - allBytes = append(allBytes, '\n') - - if verbose { - fmt.Printf("%s\n", bytes) - } - } + scanner := bufio.NewScanner(reader) + for scanner.Scan() { + bytes := scanner.Bytes() + allBytes = append(allBytes, bytes...) + allBytes = append(allBytes, '\n') if verbose { - fmt.Print("=================================================\n\n\n") + fmt.Printf("%s\n", bytes) } + } - if err := scanner.Err(); err != nil { - return files, fmt.Errorf("error reading from command output: %v", err) - } + if verbose { + fmt.Print("=================================================\n\n\n") + } + + if err := scanner.Err(); err != nil { + return files, fmt.Errorf("error reading from command output: %v", err) } tmpfile, err := os.CreateTemp("", "log-*.txt")