diff --git a/builder/builder.go b/builder/builder.go index a99139896f..7f59efcc0f 100644 --- a/builder/builder.go +++ b/builder/builder.go @@ -26,6 +26,7 @@ import ( "github.com/docker/docker/pkg/parsers" "github.com/docker/docker/pkg/symlink" "github.com/docker/docker/pkg/system" + "github.com/docker/docker/pkg/tarsum" "github.com/docker/docker/registry" "github.com/docker/docker/runconfig" "github.com/docker/docker/utils" @@ -50,7 +51,7 @@ type buildFile struct { config *runconfig.Config contextPath string - context *utils.TarSum + context *tarsum.TarSum verbose bool utilizeCache bool @@ -555,7 +556,7 @@ func (b *buildFile) runContextCommand(args string, allowRemote bool, allowDecomp if err != nil { return err } - tarSum := &utils.TarSum{Reader: r, DisableCompression: true} + tarSum := &tarsum.TarSum{Reader: r, DisableCompression: true} if _, err := io.Copy(ioutil.Discard, tarSum); err != nil { return err } @@ -777,7 +778,7 @@ func (b *buildFile) Build(context io.Reader) (string, error) { return "", err } - b.context = &utils.TarSum{Reader: decompressedStream, DisableCompression: true} + b.context = &tarsum.TarSum{Reader: decompressedStream, DisableCompression: true} if err := archive.Untar(b.context, tmpdirPath, nil); err != nil { return "", err } diff --git a/utils/tarsum.go b/pkg/tarsum/tarsum.go similarity index 96% rename from utils/tarsum.go rename to pkg/tarsum/tarsum.go index afdf128ce6..5f562762b7 100644 --- a/utils/tarsum.go +++ b/pkg/tarsum/tarsum.go @@ -1,16 +1,18 @@ -package utils +package tarsum import ( "bytes" "compress/gzip" "crypto/sha256" "encoding/hex" - "github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar" "hash" "io" "sort" "strconv" "strings" + + "github.com/docker/docker/utils" + "github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar" ) type TarSum struct { @@ -168,11 +170,11 @@ func (ts *TarSum) Sum(extra []byte) string { h.Write(extra) } for _, sum := range sums { - Debugf("-->%s<--", sum) + utils.Debugf("-->%s<--", sum) h.Write([]byte(sum)) } checksum := "tarsum+sha256:" + hex.EncodeToString(h.Sum(nil)) - Debugf("checksum processed: %s", checksum) + utils.Debugf("checksum processed: %s", checksum) return checksum } diff --git a/utils/tarsum_test.go b/pkg/tarsum/tarsum_test.go similarity index 99% rename from utils/tarsum_test.go rename to pkg/tarsum/tarsum_test.go index 7904292ddf..f251f0993f 100644 --- a/utils/tarsum_test.go +++ b/pkg/tarsum/tarsum_test.go @@ -1,4 +1,4 @@ -package utils +package tarsum import ( "bytes" diff --git a/registry/registry.go b/registry/registry.go index 0d4f2b3cc7..106a518141 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -26,6 +26,7 @@ import ( "github.com/docker/docker/dockerversion" "github.com/docker/docker/pkg/httputils" "github.com/docker/docker/pkg/parsers/kernel" + "github.com/docker/docker/pkg/tarsum" "github.com/docker/docker/utils" ) @@ -638,7 +639,7 @@ func (r *Registry) PushImageLayerRegistry(imgID string, layer io.Reader, registr utils.Debugf("[registry] Calling PUT %s", registry+"images/"+imgID+"/layer") - tarsumLayer := &utils.TarSum{Reader: layer} + tarsumLayer := &tarsum.TarSum{Reader: layer} h := sha256.New() h.Write(jsonRaw) h.Write([]byte{'\n'})