Skip to content

Commit

Permalink
chore: refactor output buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Sep 29, 2023
1 parent 432d703 commit 09a5d03
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions internal/lagoon/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"errors"
"fmt"
"io"
"io/ioutil"
"strconv"
"time"
Expand Down Expand Up @@ -267,12 +268,16 @@ func ExecTaskInPod(
return "", fmt.Errorf("error while creating Executor: %v", err)
}

var output bytes.Buffer
var stdOut, stdErr bytes.Buffer
err = exec.Stream(remotecommand.StreamOptions{
Stdout: &output,
Stderr: &output,
Stdout: &stdOut,
Stderr: &stdErr,
Tty: tty,
})
buffers := []io.Reader{&stdOut, &stdErr}
var output bytes.Buffer
reader := io.MultiReader(buffers...)
output.ReadFrom(reader)
if err != nil {
return output.String(), fmt.Errorf("Error returned: %v", err)
}
Expand Down

0 comments on commit 09a5d03

Please sign in to comment.