fix CI after containerd update

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
docker-18.09
Tonis Tiigi 2017-08-28 11:41:53 -07:00
parent 701230e83e
commit 41ca1c3ce5
1 changed files with 25 additions and 3 deletions

View File

@ -192,8 +192,18 @@ func (i *inMemoryIngester) Reader(ctx context.Context, dgst digest.Digest) (io.R
return ioutil.NopCloser(rdr), nil
}
func (i *inMemoryIngester) ReaderAt(ctx context.Context, dgst digest.Digest) (io.ReaderAt, error) {
return i.reader(ctx, dgst)
type ReaderAt interface {
io.ReaderAt
io.Closer
Size() int64
}
func (i *inMemoryIngester) ReaderAt(ctx context.Context, dgst digest.Digest) (content.ReaderAt, error) {
r, err := i.reader(ctx, dgst)
if err != nil {
return nil, err
}
return &contentReaderAt{r}, nil
}
func (i *inMemoryIngester) reader(ctx context.Context, dgst digest.Digest) (*bytes.Reader, error) {
@ -213,6 +223,18 @@ func (i *inMemoryIngester) addMap(k digest.Digest, dt []byte) {
i.buffers[k] = dt
}
type contentReaderAt struct {
*bytes.Reader
}
func (c *contentReaderAt) Close() error {
return nil
}
func (c *contentReaderAt) Size() int64 {
return int64(c.Reader.Len())
}
type bufferedWriter struct {
ingester *inMemoryIngester
ref string
@ -255,7 +277,7 @@ func (w *bufferedWriter) Digest() digest.Digest {
return w.digester.Digest()
}
func (w *bufferedWriter) Commit(size int64, expected digest.Digest) error {
func (w *bufferedWriter) Commit(size int64, expected digest.Digest, opt ...content.Opt) error {
if w.buffer == nil {
return errors.Errorf("can't commit already committed or closed")
}