Documentation ¶
Index ¶
- Variables
- func FindImage(imagesDir string, imageRef name.Reference) (v1.Image, error)
- func GetOpener(fileName string) (tarball.Opener, error)
- func MultiReadCloser(r io.ReadCloser, c io.Closer) io.ReadCloser
- func SplitReadCloser(r io.Reader, c io.Closer) io.ReadCloser
- func ZstdReadCloser(r *zstd.Decoder, c io.Closer) io.ReadCloser
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("image not found") // This needs to be kept in sync with the decompressor list SupportedExtensions = []string{".tar", ".tar.lz4", ".tar.bz2", ".tbz", ".tar.gz", ".tgz", ".tar.zst", ".tzst"} // The zstd decoder will attempt to use up to 1GB memory for streaming operations by default, // which is excessive and will OOM low-memory devices. // NOTE: This must be at least as large as the window size used when compressing tarballs, or you // will see a "window size exceeded" error when decompressing. The zstd CLI tool uses 4MB by // default; the --long option defaults to 27 or 128M, which is still too much for a Pi3. 32MB // (--long=25) has been tested to work acceptably while still compressing by an additional 3-6% on // our datasets. MaxDecoderMemory = uint64(1 << 25) )
Functions ¶
func FindImage ¶
FindImage checks tarball files in a given directory for a copy of the referenced image. The image reference must be a Tag, not a Digest. The image is retrieved from the first file (ordered by name) that it is found in; there is no preference in terms of compression format. If the image is not found in any file in the given directory, a NotFoundError is returned.
func GetOpener ¶ added in v0.5.1
GetOpener returns a function implementing the tarball.Opener interface. This is required because compressed tarballs are not seekable, and the image reader may need to seek backwards in the file to find a required layer. Instead of seeking backwards, it just closes and reopens the file. If the file format is not supported, an error is returned.
func MultiReadCloser ¶
func MultiReadCloser(r io.ReadCloser, c io.Closer) io.ReadCloser
MultiReadCloser implements the ReadCloser interface for decompressors that need to be closed. Some decompressors implement a Close function that needs to be called to clean up resources or verify checksums, but we also need to ensure that the underlying file gets closed as well.
func SplitReadCloser ¶
SplitReadCloser implements the ReadCloser interface for decompressors that don't need to be closed. Some decompressors don't implement a Close function, so we just need to ensure that the underlying file gets closed.
func ZstdReadCloser ¶
ZstdReadCloser implements the ReadCloser interface for zstd. The zstd decompressor's Close() method doesn't have a return value and therefore doesn't match the ReadCloser interface, so we have to wrap it in our own ReadCloser that doesn't expect a return value. We also need to close the underlying filehandle.
Types ¶
This section is empty.