Skip to content

Commit

Permalink
Merge pull request moby#7324 from erikh/move_tarsum
Browse files Browse the repository at this point in the history
Move tarsum to pkg/
  • Loading branch information
tiborvass committed Jul 31, 2014
2 parents 1f2d757 + ff02bea commit 531f590
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 9 deletions.
7 changes: 4 additions & 3 deletions builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -50,7 +51,7 @@ type buildFile struct {
config *runconfig.Config

contextPath string
context *utils.TarSum
context *tarsum.TarSum

verbose bool
utilizeCache bool
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
10 changes: 6 additions & 4 deletions utils/tarsum.go → pkg/tarsum/tarsum.go
Original file line number Diff line number Diff line change
@@ -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"
"log"
"sort"
"strconv"
"strings"

"github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar"
)

type TarSum struct {
Expand Down Expand Up @@ -168,11 +170,11 @@ func (ts *TarSum) Sum(extra []byte) string {
h.Write(extra)
}
for _, sum := range sums {
Debugf("-->%s<--", sum)
log.Printf("-->%s<--", sum)
h.Write([]byte(sum))
}
checksum := "tarsum+sha256:" + hex.EncodeToString(h.Sum(nil))
Debugf("checksum processed: %s", checksum)
log.Printf("checksum processed: %s", checksum)
return checksum
}

Expand Down
2 changes: 1 addition & 1 deletion utils/tarsum_test.go → pkg/tarsum/tarsum_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package utils
package tarsum

import (
"bytes"
Expand Down
3 changes: 2 additions & 1 deletion registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,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"
)

Expand Down Expand Up @@ -639,7 +640,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'})
Expand Down

0 comments on commit 531f590

Please sign in to comment.