cache

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: Apache-2.0 Imports: 21 Imported by: 6

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Destination

func Destination(opts *config.KanikoOptions, cacheKey string) (string, error)

Destination returns the repo where the layer should be stored If no cache is specified, one is inferred from the destination provided

func IsAlreadyCached added in v0.16.0

func IsAlreadyCached(err error) bool

IsAlreadyCached returns true if the supplied error is of the type AlreadyCachedErr otherwise it returns false.

func IsExpired added in v0.16.0

func IsExpired(err error) bool

IsExpired returns true if the supplied error is of the type ExpiredErr otherwise it returns false.

func IsNotFound added in v0.16.0

func IsNotFound(err error) bool

IsNotFound returns true if the supplied error is of the type NotFoundErr otherwise it returns false.

func LocalSource added in v0.5.0

func LocalSource(opts *config.CacheOptions, cacheKey string) (v1.Image, error)

LocalSource retrieves a source image from a local cache given cacheKey

func WarmCache added in v0.5.0

func WarmCache(opts *config.WarmerOptions) error

WarmCache populates the cache

Types

type AlreadyCachedErr added in v0.16.0

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

AlreadyCachedErr is returned when the Docker image requested for caching is already present in the cache.

func (AlreadyCachedErr) Error added in v0.16.0

func (a AlreadyCachedErr) Error() string

type ExpiredErr added in v0.16.0

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

ExpiredErr is returned when the requested Docker image is present in the cache, but is expired according to the supplied TTL.

func (ExpiredErr) Error added in v0.16.0

func (e ExpiredErr) Error() string

type FetchLocalSource added in v0.16.0

type FetchLocalSource func(*config.CacheOptions, string) (v1.Image, error)

FetchLocalSource retrieves a Docker image manifest from a local source. github.com/GoogleContainerTools/kaniko/cache.LocalSource can be used as this type.

type FetchRemoteImage added in v0.16.0

type FetchRemoteImage func(image string, opts config.RegistryOptions, customPlatform string) (v1.Image, error)

FetchRemoteImage retrieves a Docker image manifest from a remote source. github.com/GoogleContainerTools/kaniko/image/remote.RetrieveRemoteImage can be used as this type.

type LayerCache added in v0.6.0

type LayerCache interface {
	RetrieveLayer(string) (v1.Image, error)
}

LayerCache is the layer cache

type LayoutCache added in v1.9.2

type LayoutCache struct {
	Opts *config.KanikoOptions
}

LayoutCache is the OCI image layout cache

func (*LayoutCache) RetrieveLayer added in v1.9.2

func (lc *LayoutCache) RetrieveLayer(ck string) (v1.Image, error)

type NotFoundErr added in v0.16.0

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

NotFoundErr is returned when the requested Docker image is not present in the cache.

func (NotFoundErr) Error added in v0.16.0

func (e NotFoundErr) Error() string

type RegistryCache added in v0.6.0

type RegistryCache struct {
	Opts *config.KanikoOptions
}

RegistryCache is the registry cache

func (*RegistryCache) RetrieveLayer added in v0.6.0

func (rc *RegistryCache) RetrieveLayer(ck string) (v1.Image, error)

RetrieveLayer retrieves a layer from the cache given the cache key ck.

type Warmer added in v0.16.0

type Warmer struct {
	Remote         FetchRemoteImage
	Local          FetchLocalSource
	TarWriter      io.Writer
	ManifestWriter io.Writer
}

Warmer is used to prepopulate the cache with a Docker image

func (*Warmer) Warm added in v0.16.0

func (w *Warmer) Warm(image string, opts *config.WarmerOptions) (v1.Hash, error)

Warm retrieves a Docker image and populates the supplied buffer with the image content and manifest or returns an AlreadyCachedErr if the image is present in the cache.

Example
tarBuf := new(bytes.Buffer)
manifestBuf := new(bytes.Buffer)
w := &Warmer{
	Remote:         remote.RetrieveRemoteImage,
	Local:          LocalSource,
	TarWriter:      tarBuf,
	ManifestWriter: manifestBuf,
}

options := &config.WarmerOptions{}

digest, err := w.Warm("ubuntu:latest", options)
if err != nil {
	if !IsAlreadyCached(err) {
		log.Fatal(err)
	}
}

log.Printf("digest %v tar len %d\nmanifest:\n%s\n", digest, tarBuf.Len(), manifestBuf.String())
Output:

Jump to

Keyboard shortcuts

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