package compression

import "github.com/moby/buildkit/util/compression"

Index

Variables

var (
	// Uncompressed indicates no compression.
	Uncompressed = uncompressedType{}

	// Gzip is used for blob data.
	Gzip = gzipType{}

	// EStargz is used for estargz data.
	EStargz = estargzType{}

	// Zstd is used for Zstandard data.
	Zstd = zstdType{}
)
var Default = Gzip

Functions

func ConvertAllLayerMediaTypes

func ConvertAllLayerMediaTypes(ctx context.Context, oci bool, descs ...ocispecs.Descriptor) []ocispecs.Descriptor

func DetectLayerMediaType

func DetectLayerMediaType(ctx context.Context, cs content.Store, id digest.Digest, oci bool) (string, error)

DetectLayerMediaType returns media type from existing blob data.

func IsMediaType

func IsMediaType(ct Type, mt string) bool

Types

type Compressor

type Compressor func(dest io.Writer, mediaType string) (io.WriteCloser, error)

type Config

type Config struct {
	Type  Type
	Force bool
	Level *int
}

func New

func New(t Type) Config

func ParseAttributes

func ParseAttributes(attrs map[string]string) (Config, error)

func (Config) SetForce

func (c Config) SetForce(v bool) Config

func (Config) SetLevel

func (c Config) SetLevel(l int) Config

type Decompressor

type Decompressor func(ctx context.Context, cs content.Store, desc ocispecs.Descriptor) (io.ReadCloser, error)

type Finalizer

type Finalizer func(context.Context, content.Store) (map[string]string, error)

type Type

type Type interface {
	Compress(ctx context.Context, comp Config) (compressorFunc Compressor, finalize Finalizer)
	Decompress(ctx context.Context, cs content.Store, desc ocispecs.Descriptor) (io.ReadCloser, error)
	NeedsConversion(ctx context.Context, cs content.Store, desc ocispecs.Descriptor) (bool, error)
	NeedsComputeDiffBySelf(comp Config) bool
	OnlySupportOCITypes() bool
	MediaType() string
	String() string
}

Type represents compression type for blob data, which needs to be implemented for each compression type.

func FromMediaType

func FromMediaType(mediaType string) (Type, error)

func Parse

func Parse(t string) (Type, error)

Source Files

attrs.go compression.go estargz.go gzip.go parse.go uncompressed.go zstd.go

Version
v0.21.0 (latest)
Published
Apr 11, 2025
Platform
linux/amd64
Imports
19 packages
Last checked
2 days ago

Tools for package owners.