Documentation
¶
Index ¶
- Constants
- Variables
- func AsyncTeeReader(r io.Reader, w io.WriteCloser, bp *bufferPool) io.Reader
- func FetchHermesArtifacts(ctx context.Context, cfg config.ExternalArtifactStoreConfig, ...) (*soci.Index, error)
- func FetchSociArtifacts(ctx context.Context, refspec reference.Spec, indexDesc ocispec.Descriptor, ...) (*soci.Index, error)
- func GetContentWithRange(ctx context.Context, realURL string, rt http.RoundTripper, lower, upper int64) (*http.Response, error)
- func NewFilesystem(ctx context.Context, root string, cfg config.FSConfig, opts ...Option) (_ snapshot.FileSystem, err error)
- func NewParallelLayerUnpacker(fetcher Fetcher, archive Archive, controller LayerUnpackResourceController, ...) *parallelLayerUnpacker
- func SelectFirstPolicy(descs []ocispec.Descriptor) (ocispec.Descriptor, error)
- type Archive
- type Fetcher
- type IndexSelectionPolicy
- type Inner
- type LayerUnpackDiskStorage
- type LayerUnpackJobStorage
- type LayerUnpackResourceController
- type OCIArtifactClient
- type Option
- func WithGetSources(s source.GetSources) Option
- func WithMaxConcurrency(maxConcurrency int64) Option
- func WithMetadataStore(metadataStore metadata.Store) Option
- func WithOverlayOpaqueType(overlayOpaqueType layer.OverlayOpaqueType) Option
- func WithPullModes(pullModes config.PullModes) Option
- func WithResolveHandler(name string, handler remote.Handler) Option
- type ReferrersCaller
- type ReferrersClient
- type SemaphoreWithNil
- type Unpacker
Constants ¶
const ( LayerUnpackJobInProgress layerUnpackJobStatus = iota LayerUnpackJobClaimed LayerUnpackJobDone LayerUnpackJobFailed LayerUnpackJobCancelled )
Variables ¶
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") )
var (
ErrAllLazyPullModesDisabled = errors.New("all lazy pull modes are disabled")
)
var (
ErrNoReferrers = errors.New("no existing referrers")
)
Functions ¶
func AsyncTeeReader ¶
func FetchHermesArtifacts ¶
func FetchHermesArtifacts(ctx context.Context, cfg config.ExternalArtifactStoreConfig, imageRef, imageManifestDigest string, localStore store.Store) (*soci.Index, error)
FetchHermesArtifacts fetches the index and zTOCs from the Hermes controller, stores them in the local content store, then lets the existing lazy mount path continue unchanged for real image layer reads.
func FetchSociArtifacts ¶
func GetContentWithRange ¶
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 NewParallelLayerUnpacker ¶
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 ¶
type LayerUnpackDiskStorage struct {
// contains filtered or unexported fields
}
LayerUnpackDiskStorage persists image unpack jobs to disk.
func (LayerUnpackDiskStorage) Create ¶
func (disk LayerUnpackDiskStorage) Create() (string, error)
Create an unpack job on disk with a unique identifier.
func (LayerUnpackDiskStorage) Delete ¶
func (disk LayerUnpackDiskStorage) Delete(id string) error
Delete the specified layer unpack job from disk.
func (LayerUnpackDiskStorage) GetJobPath ¶
func (disk LayerUnpackDiskStorage) GetJobPath(id string) (string, error)
func (LayerUnpackDiskStorage) Keys ¶
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 ¶
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 ¶
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 ¶
func (c *OCIArtifactClient) SelectReferrer(ctx context.Context, desc ocispec.Descriptor, fn IndexSelectionPolicy) (ocispec.Descriptor, error)
type Option ¶
type Option func(*options)
func WithGetSources ¶
func WithGetSources(s source.GetSources) Option
func WithMaxConcurrency ¶
func WithMetadataStore ¶
func WithOverlayOpaqueType ¶
func WithOverlayOpaqueType(overlayOpaqueType layer.OverlayOpaqueType) Option
func WithPullModes ¶
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 ¶
type SemaphoreWithNil struct {
// contains filtered or unexported fields
}
func NewSemaphoreWithNil ¶
func NewSemaphoreWithNil(n int64) *SemaphoreWithNil
func (*SemaphoreWithNil) Acquire ¶
func (s *SemaphoreWithNil) Acquire(ctx context.Context, n int64) error
func (*SemaphoreWithNil) Release ¶
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
}