vendor containers/storage v1.12.11

vendor cs with overlay caching

cs also carries a dep on github.com/DataDog/zstd

Signed-off-by: baude <bbaude@redhat.com>
This commit is contained in:
baude
2019-06-20 15:05:29 -05:00
parent 1fad6b74f2
commit 7e4d75eb8b
93 changed files with 58924 additions and 61 deletions

View File

@@ -98,6 +98,8 @@ const (
Gzip
// Xz is xz compression algorithm.
Xz
// Zstd is zstd compression algorithm.
Zstd
)
const (
@@ -141,6 +143,7 @@ func DetectCompression(source []byte) Compression {
Bzip2: {0x42, 0x5A, 0x68},
Gzip: {0x1F, 0x8B, 0x08},
Xz: {0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00},
Zstd: {0x28, 0xb5, 0x2f, 0xfd},
} {
if len(source) < len(m) {
logrus.Debug("Len too short")
@@ -200,6 +203,8 @@ func DecompressStream(archive io.Reader) (io.ReadCloser, error) {
<-chdone
return readBufWrapper.Close()
}), nil
case Zstd:
return zstdReader(buf)
default:
return nil, fmt.Errorf("Unsupported compression format %s", (&compression).Extension())
}
@@ -217,6 +222,8 @@ func CompressStream(dest io.Writer, compression Compression) (io.WriteCloser, er
gzWriter := gzip.NewWriter(dest)
writeBufWrapper := p.NewWriteCloserWrapper(buf, gzWriter)
return writeBufWrapper, nil
case Zstd:
return zstdWriter(dest)
case Bzip2, Xz:
// archive/bzip2 does not support writing, and there is no xz support at all
// However, this is not a problem as docker only currently generates gzipped tars
@@ -324,6 +331,8 @@ func (compression *Compression) Extension() string {
return "tar.gz"
case Xz:
return "tar.xz"
case Zstd:
return "tar.zst"
}
return ""
}

View File

@@ -0,0 +1,17 @@
// +build cgo
package archive
import (
"io"
"github.com/DataDog/zstd"
)
func zstdReader(buf io.Reader) (io.ReadCloser, error) {
return zstd.NewReader(buf), nil
}
func zstdWriter(dest io.Writer) (io.WriteCloser, error) {
return zstd.NewWriter(dest), nil
}

View File

@@ -0,0 +1,16 @@
// +build !cgo
package archive
import (
"fmt"
"io"
)
func zstdReader(buf io.Reader) (io.ReadCloser, error) {
return nil, fmt.Errorf("zstd not supported on this platform")
}
func zstdWriter(dest io.Writer) (io.WriteCloser, error) {
return nil, fmt.Errorf("zstd not supported on this platform")
}