diff --git a/go.mod b/go.mod index e3468936..beb059da 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ replace ( require ( github.com/Azure/go-autorest/autorest v0.1.0 // indirect - github.com/derailed/tview v0.1.10 + github.com/derailed/tview v0.1.11 github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c // indirect github.com/elazarl/goproxy v0.0.0-20190421051319-9d40249d3c2f // indirect github.com/elazarl/goproxy/ext v0.0.0-20190421051319-9d40249d3c2f // indirect diff --git a/go.sum b/go.sum index cd37b58e..7331a3cc 100644 --- a/go.sum +++ b/go.sum @@ -37,6 +37,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/derailed/tview v0.1.10 h1:QWjK82ccTl3C7Tfyfmv765eRqEt/T3aXp40464cfnlw= github.com/derailed/tview v0.1.10/go.mod h1:g+ZyIsV5osK+lQ6LajiGQeLW10BQLJ6aMvy8Ldt2oa0= +github.com/derailed/tview v0.1.11 h1:aHe5bNiKC27qRLjjyu54Xoq6bRdtW3S0//r34rHzUbU= +github.com/derailed/tview v0.1.11/go.mod h1:g+ZyIsV5osK+lQ6LajiGQeLW10BQLJ6aMvy8Ldt2oa0= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c h1:ZfSZ3P3BedhKGUhzj7BQlPSU4OvT6tfOKe3DVHzOA7s= diff --git a/internal/resource/pod.go b/internal/resource/pod.go index c1e013ec..5e8b8d4a 100644 --- a/internal/resource/pod.go +++ b/internal/resource/pod.go @@ -193,23 +193,13 @@ func tailLogs(ctx context.Context, res k8s.Loggable, c chan<- string, opts LogOp return nil } -func logsTimeout(blocked int32, c chan<- string, opts LogOptions) { - select { - case <-time.After(defaultTimeout): - if atomic.LoadInt32(&blocked) == 1 { - log.Debug().Msgf("Closing channel %s:%s", opts.Name, opts.Container) - } - } -} - func readLogs(ctx context.Context, stream io.ReadCloser, c chan<- string, opts LogOptions) { defer func() { log.Debug().Msgf("Closing stream `%s", opts.Path()) stream.Close() }() - head := opts.NormalizeName() - scanner := bufio.NewScanner(stream) + scanner, head := bufio.NewScanner(stream), opts.NormalizeName() for scanner.Scan() { txt := scanner.Text() select { @@ -222,6 +212,15 @@ func readLogs(ctx context.Context, stream io.ReadCloser, c chan<- string, opts L } } +func logsTimeout(blocked int32, c chan<- string, opts LogOptions) { + select { + case <-time.After(defaultTimeout): + if atomic.LoadInt32(&blocked) == 1 { + log.Debug().Msgf("Closing channel %s:%s", opts.Name, opts.Container) + } + } +} + // List resources for a given namespace. func (r *Pod) List(ns string) (Columnars, error) { pods, err := r.Resource.List(ns)