Documentation
¶
Overview ¶
Package cache implements local cached storage of part data.
The cache is accessed using an interface defined as MoteCache, and implemented with BottleFileCache Generally, the cache is intended to be used in a pull-through fashion, with data being transferred first to the cache and then automatically to its final destination. Items in the cache are identified using a digest, though the source of those digests are generally within an oci descriptor.
Index ¶
- func LocateLayer(ctx context.Context, bic BIC, desc ocispec.Descriptor, destRef ref.Ref, ...) []ref.Ref
- func LocateLayerDigest(ctx context.Context, bic BIC, dgst digest.Digest, destRef ref.Ref, ...) []ref.Ref
- func NewFileMounter(root string, storage orascontent.Storage) (orascontent.Storage, error)
- func NewPredecessorCacher(storage orascontent.Storage) orascontent.GraphStorage
- func Prune(ctx context.Context, root string, maxSize int64) error
- func RecordLayerSource(ctx context.Context, bic BIC, desc ocispec.Descriptor, srcRef ref.Ref)
- func TransportFromImageName(refString string) string
- type BIC
- type BytesTracker
- type LayerBlobInfo
- type NilCache
- func (nc *NilCache) Exists(ctx context.Context, target ocispec.Descriptor) (bool, error)
- func (nc *NilCache) Fetch(ctx context.Context, desc ocispec.Descriptor) (io.ReadCloser, error)
- func (nc *NilCache) Predecessors(ctx context.Context, node ocispec.Descriptor) ([]ocispec.Descriptor, error)
- func (nc *NilCache) Push(ctx context.Context, expected ocispec.Descriptor, content io.Reader) error
- type PredecessorCacher
- func (pc *PredecessorCacher) Exists(ctx context.Context, target ocispec.Descriptor) (bool, error)
- func (pc *PredecessorCacher) Fetch(ctx context.Context, desc ocispec.Descriptor) (io.ReadCloser, error)
- func (pc *PredecessorCacher) Predecessors(ctx context.Context, node ocispec.Descriptor) ([]ocispec.Descriptor, error)
- func (pc *PredecessorCacher) Push(ctx context.Context, expected ocispec.Descriptor, content io.Reader) error
- type SourceProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LocateLayer ¶
func LocateLayer(ctx context.Context, bic BIC, desc ocispec.Descriptor, destRef ref.Ref, matchReg bool) []ref.Ref
LocateLayer returns a set of bottle Refs containing a list of known locations for the provided layer descriptor. The layer descriptor should be manifest-level (eg. possibly compressed/encrypted). Candidates returned will be located on the destination registry if matchReg is true.
func LocateLayerDigest ¶
func LocateLayerDigest(ctx context.Context, bic BIC, dgst digest.Digest, destRef ref.Ref, matchReg bool) []ref.Ref
LocateLayerDigest performs a layer location query based on a digest representation of the layer digest. This works the same as LocateLayer.
func NewFileMounter ¶
func NewFileMounter(root string, storage orascontent.Storage) (orascontent.Storage, error)
NewFileMounter returns a FileMounter as an oras content.Storage.
fileMounter wraps an oras content.Storage push func with file linking. Must only be used with content.Storage interfaces that use the local filesystem to store blobs.
func NewPredecessorCacher ¶
func NewPredecessorCacher(storage orascontent.Storage) orascontent.GraphStorage
NewPredecessorCacher extends and oras content.Storage to a content.GraphStorage by storing predecessors in-memory.
func Prune ¶
Prune removes files until the total size of the cache is less than or equal to maxSize.
func RecordLayerSource ¶
RecordLayerSource adds the layer described by desc to the local blob info cache, with the provided srcRef as the known source location. The desc should describe the manifest-level layer (eg, possibly compressed/encrypted).
func TransportFromImageName ¶
TransportFromImageName extracts a transport string from the provided ref string, if one exists. This allows filtering on location, such as images located in an oci-layout dir, archive, etc. If a transport string isn't found in the refString, (format is transport:ref), or if an unknown transport is specified, "oci" is returned.
Types ¶
type BytesTracker ¶
type BytesTracker struct { // Total number of bytes of bytes seen so far Total int64 // Total number of bytes seen so far with duplicates removed Deduplicated int64 // contains filtered or unexported fields }
BytesTracker is an object for tracking digests seen, total bytes seen, and deduplication size.
func (*BytesTracker) Add ¶
func (bt *BytesTracker) Add(desc ocispec.Descriptor)
Add adds a digest to the BytesTracker map and computes the total size and deduplicated size.
type LayerBlobInfo ¶
type LayerBlobInfo struct {
// contains filtered or unexported fields
}
LayerBlobInfo is a structure implementing the SourceProvider interface, enabling lookup and server-to server transfer for layers based on recorded source information in blobinfocache.
func (*LayerBlobInfo) GetSources ¶
func (lbi *LayerBlobInfo) GetSources(ctx context.Context, bic BIC) map[digest.Digest][]string
GetSources returns a map of layerID to known source list for all layerIDs in a LayerBlobInfo, implementing the SourceProvider interface.
type NilCache ¶
type NilCache struct { }
NilCache implements oras content.GraphStorage with empty functionality for cases when caching is disabled.
func (*NilCache) Fetch ¶
func (nc *NilCache) Fetch(ctx context.Context, desc ocispec.Descriptor) (io.ReadCloser, error)
Fetch is not supported.
func (*NilCache) Predecessors ¶
func (nc *NilCache) Predecessors(ctx context.Context, node ocispec.Descriptor) ([]ocispec.Descriptor, error)
Predecessors always returns an empty set.
type PredecessorCacher ¶
type PredecessorCacher struct { // Storage is where fetches/existence checks originate from and pushes are forwarded to. orascontent.Storage // contains filtered or unexported fields }
PredecessorCacher wraps an oras content.Storage to cache referrers included in manifests during Fetch, Push, and Exists operations. It is not efficient for remote storages, and is ideal for a local file-based implementation. Implements oras.GraphStorage.
func (*PredecessorCacher) Exists ¶
func (pc *PredecessorCacher) Exists(ctx context.Context, target ocispec.Descriptor) (bool, error)
Exists ultimately returns the same value as a call to Exists to the underlying content.Storage. If the target descriptor exists and has an image manifest or index mediatype it will fetch from the underlying storage and add establish a predecessor if applicable.
func (*PredecessorCacher) Fetch ¶
func (pc *PredecessorCacher) Fetch(ctx context.Context, desc ocispec.Descriptor) (io.ReadCloser, error)
Fetch first fetches the blob from the underlying content.Storage. If the descriptor has an image manifest or index mediatype it will read the manifest into memory, establish a predecessor if applicable, finally returning a io.ReadCloser for the in-memory manifest.
func (*PredecessorCacher) Predecessors ¶
func (pc *PredecessorCacher) Predecessors(ctx context.Context, node ocispec.Descriptor) ([]ocispec.Descriptor, error)
Predecessors finds the nodes directly pointing to a given node of a directed acyclic graph. In other words, returns the "parents" of the current descriptor. Predecessors implements oras content.PredecessorFinder, and is an extension of oras conent.Storage.
Predecessors returns an error if the FileCache was not initialized with the WithPredecessors Option.
func (*PredecessorCacher) Push ¶
func (pc *PredecessorCacher) Push(ctx context.Context, expected ocispec.Descriptor, content io.Reader) error
Push will read the content into memory if the expected descriptor has an image manifest or index mediatype, establish a predecessor if applicable, finally propagating the push to the underlying content.Storage.
type SourceProvider ¶
type SourceProvider interface { // GetSources returns a map of digests to a list of OCI references (in string format) where each digest is known to // exist. This allows the content to be retrieved from a remote source. GetSources() map[digest.Digest][]string }
SourceProvider is an interface enabling the retrieval of file sources, which is a mapping of digest string to list of OCI Refs in string format, allowing content to be retrieved from a remote source.
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package bicbackend implements the management and storage of blob info cache data, including boltdb and memory implementations.
|
Package bicbackend implements the management and storage of blob info cache data, including boltdb and memory implementations. |