byteCounter tests
This commit is contained in:
@@ -9,7 +9,10 @@ go_library(
|
||||
],
|
||||
importpath = "github.com/motiejus/code/undocker/rootfs",
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["@org_uber_go_multierr//:go_default_library"],
|
||||
deps = [
|
||||
"//src/undocker/internal/bytecounter:go_default_library",
|
||||
"@org_uber_go_multierr//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_test(
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/motiejus/code/undocker/internal/bytecounter"
|
||||
"go.uber.org/multierr"
|
||||
)
|
||||
|
||||
@@ -39,12 +40,12 @@ func New(rd io.ReadSeeker) *RootFS {
|
||||
|
||||
// WriteTo writes a docker image to an open tarball.
|
||||
func (r *RootFS) WriteTo(w io.Writer) (n int64, err error) {
|
||||
wr := &byteCounter{rw: w}
|
||||
wr := bytecounter.New(w)
|
||||
tr := tar.NewReader(r.rd)
|
||||
tw := tar.NewWriter(wr)
|
||||
defer func() {
|
||||
err = multierr.Append(err, tw.Close())
|
||||
n = wr.n
|
||||
n = wr.N
|
||||
}()
|
||||
|
||||
// layerOffsets maps a layer name (a9b123c0daa/layer.tar) to it's offset
|
||||
|
||||
Reference in New Issue
Block a user