Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: combined task output to single stream to retain order #221

Merged
merged 5 commits into from
Oct 9, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: refactor output buffer
shreddedbacon committed Sep 29, 2023

Verified

This commit was signed with the committer’s verified signature.
shreddedbacon Ben Jackson
commit 09a5d031d609003d9c0dc4d0d37479589d0f4965
11 changes: 8 additions & 3 deletions internal/lagoon/tasks.go
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import (
"context"
"errors"
"fmt"
"io"
"io/ioutil"
"strconv"
"time"
@@ -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)
}