fs

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 62 Imported by: 2

Documentation

Index

Constants

View Source
const (
	LayerUnpackJobInProgress layerUnpackJobStatus = iota
	LayerUnpackJobClaimed
	LayerUnpackJobDone
	LayerUnpackJobFailed
	LayerUnpackJobCancelled
)

Variables

View Source
var (
	ErrParallelPullIsDisabled = errors.New("the given config does not allow parallel pulling")

	ErrImageUnpackJobNotFound    = errors.New("image unpack job not found")
	ErrImageUnpackJobHasNoLayers = errors.New("image unpack job has no layers")
	ErrImageUnpackJobExpired     = errors.New("image unpack job has expired")
	ErrLayerHasNoJobs            = errors.New("layer has no jobs")

	ErrNoClaimableLayerJobs    = errors.New("no claimable jobs")
	ErrLayerJobNotFound        = errors.New("specified layer job not found")
	ErrLayerJobCannotBeCleaned = errors.New("layer job cannot be cleaned (is not claimed or cancelled)")

	// ErrLayerIngestDoesNotExist can occur during layer unpack operations when parallel layer download has disabled.
	ErrLayerIngestDoesNotExist = errors.New("layer ingest does not exist")

	// ErrLayerUnpackDestinationHasContent can occur during layer unpack operations. Before writing content to disk,
	// the unpacker verifies the destination directory has no pre-existing content as a layer of protection from
	// container image layer poisoning attacks.
	ErrLayerUnpackDestinationHasContent = errors.New("layer unpack destination has content")
)
View Source
var (
	ErrAllLazyPullModesDisabled = errors.New("all lazy pull modes are disabled")
)
View Source
var (
	ErrNoReferrers = errors.New("no existing referrers")
)

Functions

func AsyncTeeReader added in v0.12.0

func AsyncTeeReader(r io.Reader, w io.WriteCloser, bp *bufferPool) io.Reader

func FetchSociArtifacts

func FetchSociArtifacts(ctx context.Context, refspec reference.Spec, indexDesc ocispec.Descriptor, localStore store.Store, remoteStore resolverStorage) (*soci.Index, error)

func GetContentWithRange added in v0.12.0

func GetContentWithRange(ctx context.Context, realURL string, rt http.RoundTripper, lower, upper int64) (*http.Response, error)

GetContentWithRange gets the requested content in the byte range [lower, upper]

func NewFilesystem

func NewFilesystem(ctx context.Context, root string, cfg config.FSConfig, opts ...Option) (_ snapshot.FileSystem, err error)

func NewParallelLayerUnpacker added in v0.11.0

func NewParallelLayerUnpacker(fetcher Fetcher, archive Archive, controller LayerUnpackResourceController, discardUnpackedLayers bool) *parallelLayerUnpacker

func SelectFirstPolicy

func SelectFirstPolicy(descs []ocispec.Descriptor) (ocispec.Descriptor, error)

Types

type Archive

type Archive interface {
	// Apply decompresses the compressed stream represented by reader `r` and
	// applies it to the directory `root`.
	Apply(ctx context.Context, root string, r io.Reader, opts ...archive.ApplyOpt) (int64, error)
}

func NewLayerArchive

func NewLayerArchive(compressedVerifier, uncompressedVerifier *asyncVerifier, decompressStream socicompression.DecompressStream, bufPool *bufferPool) Archive

type Fetcher

type Fetcher interface {
	// Fetch fetches the artifact identified by the descriptor. It first checks the local content store
	// and returns a `ReadCloser` from there. Otherwise it fetches from the remote, saves in the local content store
	// and then returns a `ReadCloser`.
	Fetch(ctx context.Context, desc ocispec.Descriptor) (io.ReadCloser, bool, error)
	// Store takes in a descriptor and io.Reader and stores it in the local store.
	Store(ctx context.Context, desc ocispec.Descriptor, reader io.Reader) error
}

type IndexSelectionPolicy

type IndexSelectionPolicy func([]ocispec.Descriptor) (ocispec.Descriptor, error)

Determines which index will be selected from a list of index descriptors

type Inner

type Inner interface {
	content.Storage
	ReferrersCaller
}

type LayerUnpackDiskStorage added in v0.11.0

type LayerUnpackDiskStorage struct {
	// contains filtered or unexported fields
}

LayerUnpackDiskStorage persists image unpack jobs to disk.

func (LayerUnpackDiskStorage) Create added in v0.11.0

func (disk LayerUnpackDiskStorage) Create() (string, error)

Create an unpack job on disk with a unique identifier.

func (LayerUnpackDiskStorage) Delete added in v0.11.0

func (disk LayerUnpackDiskStorage) Delete(id string) error

Delete the specified layer unpack job from disk.

func (LayerUnpackDiskStorage) GetJobPath added in v0.11.0

func (disk LayerUnpackDiskStorage) GetJobPath(id string) (string, error)

func (LayerUnpackDiskStorage) Keys added in v0.11.0

func (disk LayerUnpackDiskStorage) Keys() ([]string, error)

Keys unpack jobs found on disk. If the root unpack directory does not exist, then an empty list will be returned with no error.

type LayerUnpackJobStorage added in v0.11.0

type LayerUnpackJobStorage interface {
	// Create an unpack job in storage and return its unique identifier.
	Create() (string, error)

	// GetJobPath returns a path on disk to use for a specified unpack job.
	GetJobPath(string) (string, error)

	// Keys lists all jobs in storage.
	Keys() ([]string, error)

	// Delete a specified unpack job from storage.
	Delete(string) error
}

LayerUnpackJobStorage defines an interface for persisting layer unpack job state to a durable storage medium.

type LayerUnpackResourceController added in v0.11.0

type LayerUnpackResourceController interface {
	// AcquireUnpackLease rate limits unpackers based on global and per image unpack concurrency limits.
	AcquireUnpackLease(context.Context) (func(), error)

	// GetUnpackIngestReader returns a reader for the compressed layer tarball on disk for unpacking.
	GetUnpackIngestReader() (io.ReadCloser, error)

	// VerifyUnpackDestinationIsReady verifies the destination for a layer unpack exists and has no pre-existing content.
	VerifyUnpackDestinationIsReady() error
}

LayerUnpackResourceController implements various controls for a layer unpack resources.

type OCIArtifactClient

type OCIArtifactClient struct {
	Inner
}

func NewOCIArtifactClient

func NewOCIArtifactClient(inner Inner) *OCIArtifactClient

func (*OCIArtifactClient) AllReferrers

func (c *OCIArtifactClient) AllReferrers(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error)

func (*OCIArtifactClient) SelectReferrer

type Option

type Option func(*options)

func WithGetSources

func WithGetSources(s source.GetSources) Option

func WithMaxConcurrency added in v0.6.0

func WithMaxConcurrency(maxConcurrency int64) Option

func WithMetadataStore

func WithMetadataStore(metadataStore metadata.Store) Option

func WithOverlayOpaqueType

func WithOverlayOpaqueType(overlayOpaqueType layer.OverlayOpaqueType) Option

func WithPullModes added in v0.10.0

func WithPullModes(pullModes config.PullModes) Option

func WithResolveHandler

func WithResolveHandler(name string, handler remote.Handler) Option

type ReferrersCaller

type ReferrersCaller interface {
	Referrers(ctx context.Context, desc ocispec.Descriptor, artifactType string, fn func(referrers []ocispec.Descriptor) error) error
}

Interface for oras-go's Repository.Referrers call, for mocking

type ReferrersClient

type ReferrersClient interface {
	/// Takes in an manifest descriptor and IndexSelectionPolicy and returns a single artifact descriptor.
	/// Returns an error (ErrNoReferrers) if the manifest descriptor has no referrers.
	SelectReferrer(context.Context, ocispec.Descriptor, IndexSelectionPolicy) (ocispec.Descriptor, error)
}

Responsible for making Referrers API calls to remote registry to fetch list of referrers.

type SemaphoreWithNil added in v0.11.0

type SemaphoreWithNil struct {
	// contains filtered or unexported fields
}

func NewSemaphoreWithNil added in v0.11.0

func NewSemaphoreWithNil(n int64) *SemaphoreWithNil

func (*SemaphoreWithNil) Acquire added in v0.11.0

func (s *SemaphoreWithNil) Acquire(ctx context.Context, n int64) error

func (*SemaphoreWithNil) Release added in v0.11.0

func (s *SemaphoreWithNil) Release(n int64)

type Unpacker

type Unpacker interface {
	// Unpack takes care of getting the layer specified by descriptor `desc`,
	// decompressing it, putting it in the directory with the path `mountpoint`
	// and applying the difference to the parent layers if there is any.
	// After that the layer can be mounted as non-remote snapshot.
	Unpack(ctx context.Context, desc ocispec.Descriptor, mountpoint string, mounts []mount.Mount) error
}

func NewLayerUnpacker

func NewLayerUnpacker(fetcher Fetcher, archive Archive) Unpacker

Directories

Path Synopsis
metrics

Jump to

Keyboard shortcuts

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