Merge pull request #7324 from erikh/move_tarsum

Move tarsum to pkg/
This commit is contained in:
Tibor Vass 2014-07-31 16:56:24 -04:00
commit 531f5907d6
8 changed files with 13 additions and 9 deletions

View file

@ -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
}

View file

@ -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 {
@ -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
}

View file

@ -1,4 +1,4 @@
package utils
package tarsum
import (
"bytes"

View file

@ -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"
)
@ -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'})