Skip to content

Commit

Permalink
Don't log image layers in debug logs (#836)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjohnsonjr committed Nov 26, 2020
1 parent 6df0303 commit cf9d7b3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/v1/remote/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"net/url"
"sync"

"github.com/google/go-containerregistry/pkg/internal/redact"
"github.com/google/go-containerregistry/pkg/name"
v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/partial"
Expand Down Expand Up @@ -142,6 +143,9 @@ func (rl *remoteImageLayer) Compressed() (io.ReadCloser, error) {
return nil, err
}

// We don't want to log binary layers -- this can break terminals.
ctx := redact.NewContext(rl.ri.context, "omitting binary blobs from logs")

for _, s := range d.URLs {
u, err := url.Parse(s)
if err != nil {
Expand All @@ -161,7 +165,7 @@ func (rl *remoteImageLayer) Compressed() (io.ReadCloser, error) {
return nil, err
}

resp, err := rl.ri.Client.Do(req.WithContext(rl.ri.context))
resp, err := rl.ri.Client.Do(req.WithContext(ctx))
if err != nil {
lastErr = err
continue
Expand Down

0 comments on commit cf9d7b3

Please sign in to comment.