cache

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 30, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheRepository

type CacheRepository interface {
	// Push stores the given data bytes under the specified reference key.
	// The reference typically matches an OCI artifact reference or URL.
	Push(ctx context.Context, reference string, data []byte) error

	// Pull retrieves a cached artifact by reference and returns the
	// local filesystem path where the data is stored.
	Pull(ctx context.Context, reference string) (string, error)
}

CacheRepository defines the interface for caching Makefile artifacts. Implementations may store artifacts locally, over HTTP, or in OCI registries.

func NewCache

func NewCache(cfg *config.Config, reference string) CacheRepository

NewCache constructs a CacheRepository based on the reference type. It inspects the reference string and returns an HTTP-based cache or an OCI repository-based cache. Returns nil for unsupported types.

func NewHTTPCache

func NewHTTPCache(cfg *config.Config) CacheRepository

NewHTTPCache returns a new HTTPCache configured with the given settings.

func NewOCIRepository

func NewOCIRepository(cfg *config.Config) CacheRepository

NewOCIRepository returns a new OCIRepository using the provided configuration.

type HTTPCache

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

HTTPCache implements CacheRepository for HTTP(S) references. It stores blobs under a directory structure based on the URL host and path, using SHA-256 digests for content addressing and symbolic links for references.

func (*HTTPCache) Pull

func (c *HTTPCache) Pull(ctx context.Context, reference string) (string, error)

Pull retrieves the cached path for the given reference URL. It reads the 'latest' symlink under 'cacheDir/host/.../refs' and returns its target. Returns an error if the cache entry does not exist or is invalid.

func (*HTTPCache) Push

func (c *HTTPCache) Push(ctx context.Context, reference string, data []byte) error

Push stores the given data bytes at a cache path derived from the reference URL. It computes a SHA-256 digest, writes the blob under 'cacheDir/host/.../blobs', and creates or updates a 'latest' symlink under 'cacheDir/host/.../refs'.

type OCIRepository

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

OCIRepository implements CacheRepository for OCI artifact references. It stores blobs under a directory structure based on registry and repository, uses SHA-256 digests for content addressing, and symlinks tags and digests under refs.

func (*OCIRepository) Pull

func (c *OCIRepository) Pull(ctx context.Context, reference string) (string, error)

Pull retrieves a cached artifact path for the given OCI reference. It looks for a symlink under 'refs/<identifier>' first. If missing and the reference is a digest, it checks the blob directly. Returns an error on cache miss.

func (*OCIRepository) Push

func (c *OCIRepository) Push(ctx context.Context, reference string, data []byte) error

Push caches the given data bytes as an OCI blob and creates a tag reference. It parses the reference (with default registry), computes SHA-256 digest, writes the blob under 'cacheDir/registry/repo/blobs', and symlinks under 'refs/<tag|digest>'.

Jump to

Keyboard shortcuts

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