blobcompress

package
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package blobcompress provides a somewhat implementation-agnostic mechanism for blobcompression and deblobcompression of an io.Reader. This is mainly intended to be used for blobcompressing tar layer blobs.

Index

Constants

This section is empty.

Variables

View Source
var Default = Gzip

Default is the default algorithm used within umoci if unspecified by a user.

Functions

func MustRegisterAlgorithm

func MustRegisterAlgorithm(algo Algorithm)

MustRegisterAlgorithm is like RegisterAlgorithm but it panics if RegisterAlgorithm returns an error. Intended for use in init functions.

func RegisterAlgorithm

func RegisterAlgorithm(algo Algorithm) error

RegisterAlgorithm adds the provided Algorithm to the set of algorithms that umoci can automatically handle when extracting images. Returns an error if another Algorithm with the same MediaTypeSuffix has already been registered.

Types

type Algorithm

type Algorithm interface {
	// MediaTypeSuffix returns the name of the blobcompression algorithm. This name
	// will be used when generating and parsing MIME type +-suffixes.
	MediaTypeSuffix() string

	// Compress sets up the streaming blobcompressor for this blobcompression type.
	Compress(plain io.Reader) (blobcompressed io.ReadCloser, _ error)

	// Deblobcompress sets up the streaming deblobcompressor for this blobcompression type.
	Decompress(blobcompressed io.Reader) (plain io.ReadCloser, _ error)
}

Algorithm is a generic representation of a compression algorithm that can be used by umoci for compressing and decompressing layer blobs. If you create a custom algorithm, you should make sure you register it with RegisterAlgorithm so that layers using the algorithm can be decompressed.

var Gzip Algorithm = gzipAlgo{}

Gzip provides concurrent gzip blobcompression and deblobcompression.

var Noop Algorithm = noopAlgo{}

Noop does no compression.

var Zstd Algorithm = zstdAlgo{}

Zstd provides zstd blobcompression and deblobcompression.

func GetAlgorithm

func GetAlgorithm(name string) Algorithm

GetAlgorithm looks for a registered Algorithm with the given MediaTypeSuffix (which doubles as its name). Return nil if no such algorithm has been registered.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址