Documentation ¶
Overview ¶
Package casext provides extensions to the standard cas.Engine interface, allowing for generic functionality to be used on top of any implementation of cas.Engine.
Index ¶
- type Blob
- type Engine
- func (e Engine) FromDescriptor(ctx context.Context, descriptor ispec.Descriptor) (*Blob, error)
- func (e Engine) GC(ctx context.Context) error
- func (e Engine) Paths(ctx context.Context, root ispec.Descriptor) ([]ispec.Descriptor, error)
- func (e Engine) Reachable(ctx context.Context, root ispec.Descriptor) ([]digest.Digest, error)
- func (e Engine) Walk(ctx context.Context, root ispec.Descriptor, walkFunc WalkFunc) error
- type WalkFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Blob ¶
type Blob struct { // MediaType is the OCI media type of Data. MediaType string // Digest is the digest of the parsed image. Note that this does not update // if Data is changed (it is the digest that this blob was parsed *from*). Digest digest.Digest // Data is the "parsed" blob taken from the OCI image's blob store, and is // typed according to the media type. The mapping from MIME => type is as // follows. // // ispec.MediaTypeDescriptor => ispec.Descriptor // ispec.MediaTypeImageManifest => ispec.Manifest // ispec.MediaTypeImageManifestList => ispec.ManifestList // ispec.MediaTypeImageLayer => io.ReadCloser // ispec.MediaTypeImageLayerGzip => io.ReadCloser // ispec.MediaTypeImageLayerNonDistributable => io.ReadCloser // ispec.MediaTypeImageLayerNonDistributableGzip => io.ReadCloser // ispec.MediaTypeImageConfig => ispec.Image Data interface{} }
Blob represents a "parsed" blob in an OCI image's blob store. MediaType offers a type-safe way of checking what the type of Data is.
type Engine ¶
Engine is a wrapper around cas.Engine that provides additional, generic extensions to the transport-dependent cas.Engine implementation.
func (Engine) FromDescriptor ¶
FromDescriptor parses the blob referenced by the given descriptor.
func (Engine) GC ¶
GC will perform a mark-and-sweep garbage collection of the OCI image referenced by the given CAS engine. The root set is taken to be the set of references stored in the image, and all blobs not reachable by following a descriptor path from the root set will be removed.
GC will only call ListBlobs and ListReferences once, and assumes that there is no change in the set of references or blobs after calling those functions. In other words, it assumes it is the only user of the image that is making modifications. Things will not go well if this assumption is challenged.
func (Engine) Paths ¶
func (e Engine) Paths(ctx context.Context, root ispec.Descriptor) ([]ispec.Descriptor, error)
Paths returns the set of descriptors that can be traversed from the provided root descriptor. It is effectively shorthand for Walk(). Note that there may be repeated descriptors in the returned slice, due to different blobs containing the same (or a similar) descriptor.
func (Engine) Reachable ¶
Reachable returns the set of digests which can be reached using a descriptor path from the provided root descriptor. It is effectively a shorthand for Walk(). The returned slice will *not* contain any duplicate digest.Digest entries. Note that without descriptors, a digest is not particularly meaninful (OCI blobs are not self-descriptive).
type WalkFunc ¶
type WalkFunc func(descriptor ispec.Descriptor) error
WalkFunc is the type of function passed to Walk. It will be a called on each descriptor encountered, recursively -- which may involve the function being called on the same descriptor multiple times (though because an OCI image is a Merkle tree there will never be any loops). If an error is returned by WalkFunc, the recursion will halt and the error will bubble up to the caller.