mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
builder: updates to session after vendor
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
parent
ed6fd3d95b
commit
d472974902
4 changed files with 55 additions and 7 deletions
|
@ -1,7 +1,10 @@
|
||||||
package fscache
|
package fscache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"archive/tar"
|
||||||
|
"crypto/sha256"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"hash"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
|
@ -11,8 +14,10 @@ import (
|
||||||
"github.com/boltdb/bolt"
|
"github.com/boltdb/bolt"
|
||||||
"github.com/docker/docker/builder"
|
"github.com/docker/docker/builder"
|
||||||
"github.com/docker/docker/builder/remotecontext"
|
"github.com/docker/docker/builder/remotecontext"
|
||||||
|
"github.com/docker/docker/pkg/archive"
|
||||||
"github.com/docker/docker/pkg/directory"
|
"github.com/docker/docker/pkg/directory"
|
||||||
"github.com/docker/docker/pkg/stringid"
|
"github.com/docker/docker/pkg/stringid"
|
||||||
|
"github.com/docker/docker/pkg/tarsum"
|
||||||
"github.com/moby/buildkit/session/filesync"
|
"github.com/moby/buildkit/session/filesync"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
@ -578,6 +583,10 @@ func (dc *detectChanges) MarkSupported(v bool) {
|
||||||
dc.supported = v
|
dc.supported = v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (dc *detectChanges) ContentHasher() fsutil.ContentHasher {
|
||||||
|
return newTarsumHash
|
||||||
|
}
|
||||||
|
|
||||||
type wrappedContext struct {
|
type wrappedContext struct {
|
||||||
builder.Source
|
builder.Source
|
||||||
closer func() error
|
closer func() error
|
||||||
|
@ -607,3 +616,40 @@ func (s sortableCacheSources) Less(i, j int) bool {
|
||||||
func (s sortableCacheSources) Swap(i, j int) {
|
func (s sortableCacheSources) Swap(i, j int) {
|
||||||
s[i], s[j] = s[j], s[i]
|
s[i], s[j] = s[j], s[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func newTarsumHash(stat *fsutil.Stat) (hash.Hash, error) {
|
||||||
|
fi := &fsutil.StatInfo{stat}
|
||||||
|
p := stat.Path
|
||||||
|
if fi.IsDir() {
|
||||||
|
p += string(os.PathSeparator)
|
||||||
|
}
|
||||||
|
h, err := archive.FileInfoHeader(p, fi, stat.Linkname)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
h.Name = p
|
||||||
|
h.Uid = int(stat.Uid)
|
||||||
|
h.Gid = int(stat.Gid)
|
||||||
|
h.Linkname = stat.Linkname
|
||||||
|
if stat.Xattrs != nil {
|
||||||
|
h.Xattrs = make(map[string]string)
|
||||||
|
for k, v := range stat.Xattrs {
|
||||||
|
h.Xattrs[k] = string(v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tsh := &tarsumHash{h: h, Hash: sha256.New()}
|
||||||
|
tsh.Reset()
|
||||||
|
return tsh, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset resets the Hash to its initial state.
|
||||||
|
func (tsh *tarsumHash) Reset() {
|
||||||
|
tsh.Hash.Reset()
|
||||||
|
tarsum.WriteV1Header(tsh.h, tsh.Hash)
|
||||||
|
}
|
||||||
|
|
||||||
|
type tarsumHash struct {
|
||||||
|
hash.Hash
|
||||||
|
h *tar.Header
|
||||||
|
}
|
||||||
|
|
|
@ -5,15 +5,15 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
iradix "github.com/hashicorp/go-immutable-radix"
|
|
||||||
|
|
||||||
"github.com/docker/docker/pkg/containerfs"
|
"github.com/docker/docker/pkg/containerfs"
|
||||||
|
iradix "github.com/hashicorp/go-immutable-radix"
|
||||||
|
digest "github.com/opencontainers/go-digest"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/tonistiigi/fsutil"
|
"github.com/tonistiigi/fsutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
type hashed interface {
|
type hashed interface {
|
||||||
Hash() string
|
Digest() digest.Digest
|
||||||
}
|
}
|
||||||
|
|
||||||
// CachableSource is a source that contains cache records for its contents
|
// CachableSource is a source that contains cache records for its contents
|
||||||
|
@ -110,7 +110,7 @@ func (cs *CachableSource) HandleChange(kind fsutil.ChangeKind, p string, fi os.F
|
||||||
}
|
}
|
||||||
|
|
||||||
hfi := &fileInfo{
|
hfi := &fileInfo{
|
||||||
sum: h.Hash(),
|
sum: h.Digest().Hex(),
|
||||||
}
|
}
|
||||||
cs.txn.Insert([]byte(p), hfi)
|
cs.txn.Insert([]byte(p), hfi)
|
||||||
cs.mu.Unlock()
|
cs.mu.Unlock()
|
||||||
|
|
|
@ -586,7 +586,9 @@ func testBuildWithSession(c *check.C, dir, dockerfile string) (outStr string) {
|
||||||
sess, err := session.NewSession("foo1", "foo")
|
sess, err := session.NewSession("foo1", "foo")
|
||||||
assert.Nil(c, err)
|
assert.Nil(c, err)
|
||||||
|
|
||||||
fsProvider := filesync.NewFSSyncProvider(dir, nil)
|
fsProvider := filesync.NewFSSyncProvider([]filesync.SyncedDir{
|
||||||
|
{Dir: dir},
|
||||||
|
})
|
||||||
sess.Allow(fsProvider)
|
sess.Allow(fsProvider)
|
||||||
|
|
||||||
g, ctx := errgroup.WithContext(context.Background())
|
g, ctx := errgroup.WithContext(context.Background())
|
||||||
|
@ -596,7 +598,7 @@ func testBuildWithSession(c *check.C, dir, dockerfile string) (outStr string) {
|
||||||
})
|
})
|
||||||
|
|
||||||
g.Go(func() error {
|
g.Go(func() error {
|
||||||
res, body, err := request.Post("/build?remote=client-session&session="+sess.UUID(), func(req *http.Request) error {
|
res, body, err := request.Post("/build?remote=client-session&session="+sess.ID(), func(req *http.Request) error {
|
||||||
req.Body = ioutil.NopCloser(strings.NewReader(dockerfile))
|
req.Body = ioutil.NopCloser(strings.NewReader(dockerfile))
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
|
@ -27,7 +27,7 @@ github.com/imdario/mergo 0.2.1
|
||||||
golang.org/x/sync de49d9dcd27d4f764488181bea099dfe6179bcf0
|
golang.org/x/sync de49d9dcd27d4f764488181bea099dfe6179bcf0
|
||||||
|
|
||||||
github.com/containerd/continuity 22694c680ee48fb8f50015b44618517e2bde77e8
|
github.com/containerd/continuity 22694c680ee48fb8f50015b44618517e2bde77e8
|
||||||
github.com/moby/buildkit c2dbdeb457ea665699a5d97f79eebfac4ab4726f https://github.com/tonistiigi/buildkit.git
|
github.com/moby/buildkit aaff9d591ef128560018433fe61beb802e149de8
|
||||||
github.com/tonistiigi/fsutil 1dedf6e90084bd88c4c518a15e68a37ed1370203
|
github.com/tonistiigi/fsutil 1dedf6e90084bd88c4c518a15e68a37ed1370203
|
||||||
|
|
||||||
#get libnetwork packages
|
#get libnetwork packages
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue