mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
utils/tarsum* -> pkg/tarsum
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
This commit is contained in:
parent
403df1765a
commit
1219e458d1
4 changed files with 13 additions and 9 deletions
|
@ -26,6 +26,7 @@ import (
|
||||||
"github.com/docker/docker/pkg/parsers"
|
"github.com/docker/docker/pkg/parsers"
|
||||||
"github.com/docker/docker/pkg/symlink"
|
"github.com/docker/docker/pkg/symlink"
|
||||||
"github.com/docker/docker/pkg/system"
|
"github.com/docker/docker/pkg/system"
|
||||||
|
"github.com/docker/docker/pkg/tarsum"
|
||||||
"github.com/docker/docker/registry"
|
"github.com/docker/docker/registry"
|
||||||
"github.com/docker/docker/runconfig"
|
"github.com/docker/docker/runconfig"
|
||||||
"github.com/docker/docker/utils"
|
"github.com/docker/docker/utils"
|
||||||
|
@ -50,7 +51,7 @@ type buildFile struct {
|
||||||
config *runconfig.Config
|
config *runconfig.Config
|
||||||
|
|
||||||
contextPath string
|
contextPath string
|
||||||
context *utils.TarSum
|
context *tarsum.TarSum
|
||||||
|
|
||||||
verbose bool
|
verbose bool
|
||||||
utilizeCache bool
|
utilizeCache bool
|
||||||
|
@ -555,7 +556,7 @@ func (b *buildFile) runContextCommand(args string, allowRemote bool, allowDecomp
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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 {
|
if _, err := io.Copy(ioutil.Discard, tarSum); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -777,7 +778,7 @@ func (b *buildFile) Build(context io.Reader) (string, error) {
|
||||||
return "", err
|
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 {
|
if err := archive.Untar(b.context, tmpdirPath, nil); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
package utils
|
package tarsum
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar"
|
|
||||||
"hash"
|
"hash"
|
||||||
"io"
|
"io"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/docker/docker/utils"
|
||||||
|
"github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TarSum struct {
|
type TarSum struct {
|
||||||
|
@ -168,11 +170,11 @@ func (ts *TarSum) Sum(extra []byte) string {
|
||||||
h.Write(extra)
|
h.Write(extra)
|
||||||
}
|
}
|
||||||
for _, sum := range sums {
|
for _, sum := range sums {
|
||||||
Debugf("-->%s<--", sum)
|
utils.Debugf("-->%s<--", sum)
|
||||||
h.Write([]byte(sum))
|
h.Write([]byte(sum))
|
||||||
}
|
}
|
||||||
checksum := "tarsum+sha256:" + hex.EncodeToString(h.Sum(nil))
|
checksum := "tarsum+sha256:" + hex.EncodeToString(h.Sum(nil))
|
||||||
Debugf("checksum processed: %s", checksum)
|
utils.Debugf("checksum processed: %s", checksum)
|
||||||
return checksum
|
return checksum
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package utils
|
package tarsum
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
|
@ -26,6 +26,7 @@ import (
|
||||||
"github.com/docker/docker/dockerversion"
|
"github.com/docker/docker/dockerversion"
|
||||||
"github.com/docker/docker/pkg/httputils"
|
"github.com/docker/docker/pkg/httputils"
|
||||||
"github.com/docker/docker/pkg/parsers/kernel"
|
"github.com/docker/docker/pkg/parsers/kernel"
|
||||||
|
"github.com/docker/docker/pkg/tarsum"
|
||||||
"github.com/docker/docker/utils"
|
"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")
|
utils.Debugf("[registry] Calling PUT %s", registry+"images/"+imgID+"/layer")
|
||||||
|
|
||||||
tarsumLayer := &utils.TarSum{Reader: layer}
|
tarsumLayer := &tarsum.TarSum{Reader: layer}
|
||||||
h := sha256.New()
|
h := sha256.New()
|
||||||
h.Write(jsonRaw)
|
h.Write(jsonRaw)
|
||||||
h.Write([]byte{'\n'})
|
h.Write([]byte{'\n'})
|
||||||
|
|
Loading…
Reference in a new issue