orasutil

package
v1.16.1 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package orasutil is a collection of oras extensions

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingSuccessor = errors.New("missing successor")

ErrMissingSuccessor indicates that a success is issing.

Functions

func NewExistenceCachedStorage

func NewExistenceCachedStorage(storage content.Storage) content.Storage

NewExistenceCachedStorage adapts a content.Storage to cache results from Exists(), Push(), Fetch() to avoid unnecessary round-trips. This is sound so long as there are no concurrent deletes issued to the Storage through another interface.

func NewNoPushStorage

func NewNoPushStorage(storage content.Storage) content.Storage

NewNoPushStorage is an oras content.Storage adapter that turns the Push() func into a no-op.

Types

type BlobCacher

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

BlobCacher wraps oras interfaces ensuring they share a persistent blob cache.

func NewBlobCacher

func NewBlobCacher(root string) (*BlobCacher, error)

NewBlobCacher returns a BlobCacher that utilizes a shared peristant file storage for all oras.GraphTargets that it creates. Safe to use if root does not yet exist.

func (*BlobCacher) GraphTarget

func (bc *BlobCacher) GraphTarget(gt oras.GraphTarget) oras.GraphTarget

GraphTarget wraps an oras.GraphTarget with a shared peristant blob storage.

type CachedGraphTarget

type CachedGraphTarget struct {
	oras.GraphTarget

	Cache orascontent.Storage
}

CachedGraphTarget implements oras.GraphTarget, preferring to fetch blobs from a persistent cache and falling back to the remote if necessary.

func (*CachedGraphTarget) Fetch

Fetch prefers to read from the local cache, falling back to the remote on misses.

func (*CachedGraphTarget) Push

func (c *CachedGraphTarget) Push(ctx context.Context, expected ocispec.Descriptor, content io.Reader) error

Push caches blobs while pushing to the remote.

type CheckedStorage

type CheckedStorage struct {
	Target oras.GraphTarget
}

CheckedStorage ensures that all successors are present before accepting a Push. This is to more closely mimic an OCI registry.

func (*CheckedStorage) Push

func (cs *CheckedStorage) Push(ctx context.Context, expected ocispec.Descriptor, r io.Reader) error

Push implements content.Fetcher and overrides that in the embedded oras.Target.

type ExistenceCachedStorage

type ExistenceCachedStorage struct {
	content.Storage
	// contains filtered or unexported fields
}

ExistenceCachedStorage checks and populates the cache on calls to Exists(), Push(), Fetch().

func (*ExistenceCachedStorage) Exists

Exists attempts to load the cached results of a previous call, falling back to the storage if not loaded.

func (*ExistenceCachedStorage) Fetch

Fetch is instrumented with a cached existence check, used before fetching from the storage.

func (*ExistenceCachedStorage) Push

Push is instrumented with a cached existence check, used before pushing to the storage.

type UnreliableStorage

type UnreliableStorage struct {
	content.Storage
}

UnreliableStorage overwrites the Exists function to consistently fetch manifests if the underlying content.GraphStorage cannot guarantee all successors also exist. Useful in a oras.CopyGraph context.

func (*UnreliableStorage) Exists

func (u *UnreliableStorage) Exists(ctx context.Context, target ocispec.Descriptor) (bool, error)

Exists overwrites the underlying content.Storage's Exists by returning false if a descriptor has a manifest or index mediatype.

Jump to

Keyboard shortcuts

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