cache

package
v1.15.9 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package cache facilitates caching git and git-lfs objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache represents a cache of git and git-lfs objects.

func NewCache

func NewCache(ctx context.Context, cachePath, fstorePath string, fstore *file.Store, cmdOpts *cmd.Options) (*Cache, error)

NewCache is a constructor for a Cache, expects cachePath to exist. The cmdOpts are only used for initialization. TODO: Should we have a default cache path? If so, this should be added to the flag not here.

func (*Cache) CachePath

func (c *Cache) CachePath() string

CachePath returns the path to the cache directory.

func (c *Cache) NewLink(ctx context.Context, cmdOpts cmd.Options) (ObjectCacher, error)

NewLink builds a new link to an existing cache, allowing for concurrent access.

type Link struct {
	*Cache

	CmdHelper *cmd.Helper
}

Link provides concurrency safe access to a git object cache. Link implements ObjectCacher.

func (*Link) UpdateFromGit

func (c *Link) UpdateFromGit(ctx context.Context, gitRemote string, argRevList ...string) error

UpdateFromGit updates the cache with objects from a remote git repository that are reachable from argRevList, or all objects if argRevList is empty.

func (*Link) UpdateFromOCI

func (c *Link) UpdateFromOCI(ctx context.Context, src content.ReadOnlyGraphStorage, manDesc ocispec.Descriptor) error

UpdateFromOCI updates the cache with the specified contents from an OCI repository.

func (*Link) UpdateLFSFromGit

func (c *Link) UpdateLFSFromGit(ctx context.Context, gitRemote string, commits ...string) error

UpdateLFSFromGit updates the cache with LFS objects from a remote git repository that are reachable from argRevList, or all objects if argRevList is empty.

func (*Link) UpdateLFSFromOCI

func (c *Link) UpdateLFSFromOCI(ctx context.Context, src content.ReadOnlyGraphStorage, lfsManDesc ocispec.Descriptor) ([]ocispec.Descriptor, error)

UpdateLFSFromOCI updates the cache with LFS objects from a remote git repository stored in OCI format that are reachable from argRevList, or all objects if argRevList is empty. Returns a list of fetched LFS OIDs.

type ObjectCacher

type ObjectCacher interface {
	CachePath() string
	UpdateFromGit(ctx context.Context, gitRemote string, argRevList ...string) error
	UpdateFromOCI(ctx context.Context, src content.ReadOnlyGraphStorage, manDesc ocispec.Descriptor) error
	UpdateLFSFromGit(ctx context.Context, gitRemote string, argRevList ...string) error
	UpdateLFSFromOCI(ctx context.Context, src content.ReadOnlyGraphStorage, lfsManDesc ocispec.Descriptor) ([]ocispec.Descriptor, error)
}

ObjectCacher proivdes methods for adding git or git-lfs objects to a cache.

Jump to

Keyboard shortcuts

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