Merge pull request #669 from tonistiigi/update-copy
dockerfile: update default copy imagedocker-18.09
commit
ab6a2dc83e
|
@ -35,7 +35,7 @@ const (
|
|||
localNameContext = "context"
|
||||
historyComment = "buildkit.dockerfile.v0"
|
||||
|
||||
DefaultCopyImage = "tonistiigi/copy:v0.1.5@sha256:eab89b76ffbb3c807663a67a41e8be31b8a0e362d7fb074a55bddace563a28bb"
|
||||
DefaultCopyImage = "tonistiigi/copy:v0.1.7@sha256:9aab7d9ab369c6daf4831bf0653f7592110ab4b7e8a33fee2b9dca546e9d3089"
|
||||
)
|
||||
|
||||
type ConvertOpt struct {
|
||||
|
|
|
@ -51,7 +51,7 @@ func init() {
|
|||
opts = []integration.TestOpt{
|
||||
integration.WithMirroredImages(integration.OfficialImages("busybox:latest")),
|
||||
integration.WithMirroredImages(map[string]string{
|
||||
"tonistiigi/copy:v0.1.5": "docker.io/" + dockerfile2llb.DefaultCopyImage,
|
||||
"tonistiigi/copy:v0.1.7": "docker.io/" + dockerfile2llb.DefaultCopyImage,
|
||||
}),
|
||||
integration.WithMatrix("frontend", frontends),
|
||||
}
|
||||
|
|
|
@ -3,11 +3,16 @@ package contentutil
|
|||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"sync"
|
||||
|
||||
"github.com/containerd/containerd/content"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/remotes"
|
||||
"github.com/containerd/containerd/remotes/docker"
|
||||
"github.com/docker/docker/pkg/locker"
|
||||
digest "github.com/opencontainers/go-digest"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func ProviderFromRef(ref string) (ocispec.Descriptor, content.Provider, error) {
|
||||
|
@ -38,11 +43,13 @@ func IngesterFromRef(ref string) (content.Ingester, error) {
|
|||
}
|
||||
|
||||
return &ingester{
|
||||
locker: locker.New(),
|
||||
pusher: pusher,
|
||||
}, nil
|
||||
}
|
||||
|
||||
type ingester struct {
|
||||
locker *locker.Locker
|
||||
pusher remotes.Pusher
|
||||
}
|
||||
|
||||
|
@ -53,5 +60,38 @@ func (w *ingester) Writer(ctx context.Context, opts ...content.WriterOpt) (conte
|
|||
return nil, err
|
||||
}
|
||||
}
|
||||
return w.pusher.Push(ctx, wo.Desc)
|
||||
if wo.Ref == "" {
|
||||
return nil, errors.Wrap(errdefs.ErrInvalidArgument, "ref must not be empty")
|
||||
}
|
||||
w.locker.Lock(wo.Ref)
|
||||
var once sync.Once
|
||||
unlock := func() {
|
||||
once.Do(func() {
|
||||
w.locker.Unlock(wo.Ref)
|
||||
})
|
||||
}
|
||||
writer, err := w.pusher.Push(ctx, wo.Desc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &lockedWriter{unlock: unlock, Writer: writer}, nil
|
||||
}
|
||||
|
||||
type lockedWriter struct {
|
||||
unlock func()
|
||||
content.Writer
|
||||
}
|
||||
|
||||
func (w *lockedWriter) Commit(ctx context.Context, size int64, expected digest.Digest, opts ...content.Opt) error {
|
||||
err := w.Writer.Commit(ctx, size, expected, opts...)
|
||||
if err == nil {
|
||||
w.unlock()
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (w *lockedWriter) Close() error {
|
||||
err := w.Writer.Close()
|
||||
w.unlock()
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -217,7 +217,7 @@ mirrors=["%s"]
|
|||
return tmpdir, nil
|
||||
}
|
||||
|
||||
func runMirror(t *testing.T, mirroredImages map[string]string) (host string, cleanup func() error, err error) {
|
||||
func runMirror(t *testing.T, mirroredImages map[string]string) (host string, _ func() error, err error) {
|
||||
mirrorDir := os.Getenv("BUILDKIT_REGISTRY_MIRROR_DIR")
|
||||
|
||||
var f *os.File
|
||||
|
|
Loading…
Reference in New Issue