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

Pipetagger: Converted Scanner to Reader #3804

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
19 changes: 15 additions & 4 deletions pkg/composer/pipetagger/pipetagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import (
"bufio"
"fmt"
"github.com/containerd/log"

Check failure on line 22 in pkg/composer/pipetagger/pipetagger.go

View workflow job for this annotation

GitHub Actions / go | freebsd |

File is not properly formatted (goimports)

Check failure on line 22 in pkg/composer/pipetagger/pipetagger.go

View workflow job for this annotation

GitHub Actions / go | linux | go-canary

File is not properly formatted (goimports)
"hash/fnv"
"io"
"strings"
Expand Down Expand Up @@ -94,9 +95,15 @@
}

func (x *PipeTagger) Run() error {
scanner := bufio.NewScanner(x.r)
for scanner.Scan() {
line := scanner.Text()
r := bufio.NewReader(x.r)

var err error

for err == nil {
var s string
s, err = r.ReadString('\n')
line := strings.TrimSuffix(s, "\n")

if x.width < 0 {
fmt.Fprintln(x.w, line)
} else {
Expand All @@ -106,6 +113,10 @@
line,
)
}

if err != nil && err != io.EOF {
log.L.WithError(err).Error("failed to read log")
}
}
return scanner.Err()
return err
}
Loading