cache

package
v3.1.0-alpha.20261117 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDir = "/cache"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

func Disabled

func Disabled(fs vfs.FS) *Cache

func New

func New(dir string, opts ...Opt) (*Cache, error)

func (*Cache) Dir

func (c *Cache) Dir() string

func (*Cache) File

func (c *Cache) File(ctx context.Context, key, dest string, fetch FileFetcher) error

File places the file identified by key at dest. The file is copied from the cache when present. Otherwise downloaded and placed into cache when the settings allow it

func (*Cache) Image

Image returns the container image identified by ref for the given platform. The image is served from the cache when present. Otherwise downloaded and cached when policy allows it.

type FileFetcher

type FileFetcher func(ctx context.Context) (io.ReadCloser, error)

type ImageFetcher

type ImageFetcher func(ctx context.Context) (containerregistry.Image, error)

type Mode

type Mode string
const (
	// Auto automatically pulls and caches artifacts into the image.
	Auto Mode = "auto"
	// Offline only uses cached artifacts in the image, does not download anything and fails when something is missing.
	Offline Mode = "offline"
	// Refresh checks to see if any cached artifacts are outdated and refreshes them.
	Refresh Mode = "refresh"
	// Off no writes or reads from the cache.
	Off Mode = "off"
)

func (Mode) IsValid

func (m Mode) IsValid() bool

type Opt

type Opt func(c *Cache)

func WithFS

func WithFS(fs vfs.FS) Opt

func WithLogger

func WithLogger(logger log.Logger) Opt

func WithPolicy

func WithPolicy(policy Policy) Opt

type Policy

type Policy struct {
	Mode Mode
}

func DefaultPolicy

func DefaultPolicy() Policy

func (Policy) Validate

func (p Policy) Validate() error

Jump to

Keyboard shortcuts

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