mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-09-05 18:40:59 +00:00
Use docker’s stdcopy to ensure we don’t emit garbage bytes to stdout
This commit is contained in:
parent
588d3acce2
commit
b3c24a3df0
2 changed files with 60 additions and 6 deletions
|
@ -6,6 +6,7 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/docker/docker/pkg/stdcopy"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
|
@ -31,12 +32,10 @@ type dockerMessage struct {
|
|||
}
|
||||
|
||||
func (i *DockerExecutorInput) logDockerOutput(dockerResponse io.Reader) {
|
||||
scanner := bufio.NewScanner(dockerResponse)
|
||||
if i.Logger == nil {
|
||||
return
|
||||
}
|
||||
for scanner.Scan() {
|
||||
i.Logger.Infof(scanner.Text())
|
||||
w := i.Logger.Writer()
|
||||
_, err := stdcopy.StdCopy(w, w, dockerResponse)
|
||||
if err != nil {
|
||||
i.Logger.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue