cache

package
v0.0.0-...-18f9808 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Get

func Get(cache string) (layout.Path, error)

Get get or initialize the cache

func ListImages

func ListImages(dir string) (map[string]string, error)

ListImages list the named images and their root digests from a layout.Path

Types

type ImageSource

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

ImageSource a source for an image in the OCI distribution cache. Implements a spec.ImageSource.

func (ImageSource) Config

func (c ImageSource) Config() (imagespec.ImageConfig, error)

Config return the imagespec.ImageConfig for the given source. Resolves to the architecture, if necessary.

func (ImageSource) Descriptor

func (c ImageSource) Descriptor() *v1.Descriptor

Descriptor return the descriptor of the image.

func (ImageSource) TarReader

func (c ImageSource) TarReader() (io.ReadCloser, error)

TarReader return an io.ReadCloser to read the filesystem contents of the image, as resolved to the provided architecture.

func (ImageSource) V1TarReader

func (c ImageSource) V1TarReader(overrideName string) (io.ReadCloser, error)

V1TarReader return an io.ReadCloser to read the image as a v1 tarball

type Provider

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

Provider cache implementation of cacheProvider

func NewProvider

func NewProvider(dir string) (*Provider, error)

NewProvider create a new CacheProvider based in the provided directory

func (*Provider) DescriptorWrite

func (p *Provider) DescriptorWrite(ref *reference.Spec, desc v1.Descriptor) (lktspec.ImageSource, error)

DescriptorWrite writes a descriptor to the cache index; it validates that it has a name and replaces any existing one

func (*Provider) FindDescriptor

func (p *Provider) FindDescriptor(ref *reference.Spec) (*v1.Descriptor, error)

FindDescriptor get the first descriptor pointed to by the image reference, whether tagged or digested

func (*Provider) FindRoot

func (p *Provider) FindRoot(imageName string) (ResolvableDescriptor, error)

FindRoot find the root ResolvableDescriptor, representing an Image or Index, for a given imageName.

func (*Provider) ImageInCache

func (p *Provider) ImageInCache(ref *reference.Spec, trustedRef, architecture string) (bool, error)

func (*Provider) ImageInRegistry

func (p *Provider) ImageInRegistry(ref *reference.Spec, trustedRef, architecture string) (bool, error)

ImageInRegistry takes an image name and checks that the image manifest or index to which it refers exists in the registry.

func (*Provider) ImageLoad

func (p *Provider) ImageLoad(ref *reference.Spec, architecture string, r io.Reader) (lktspec.ImageSource, error)

ImageLoad takes an OCI format image tar stream and writes it locally. It should be efficient and only write missing blobs, based on their content hash.

func (*Provider) ImagePull

func (p *Provider) ImagePull(ref *reference.Spec, trustedRef, architecture string, alwaysPull bool) (lktspec.ImageSource, error)

ImagePull takes an image name and ensures that the image manifest or index to which it refers exists in local cache and, if not, pulls it from the registry and writes it locally. It should be efficient and only write missing blobs, based on their content hash. It will only pull the actual blobs, config and manifest for the requested architectures, even if ref points to an index with multiple architectures. If the ref and all of the content for the requested architectures already exist in the cache, it will not pull anything, unless alwaysPull is set to true. If you call it multiple times, even with different architectures, the ref will continue to point to the same index. Only the underlying content will be added.

func (*Provider) IndexWrite

func (p *Provider) IndexWrite(ref *reference.Spec, descriptors ...v1.Descriptor) (lktspec.ImageSource, error)

IndexWrite takes an image name and creates an index for the targets to which it points. does not pull down any images; entirely assumes that the subjects of the manifests are present. If a reference to the provided already exists and it is an index, updates the manifests in the existing index.

func (*Provider) List

func (p *Provider) List() (map[string]string, error)

func (*Provider) NewSource

func (p *Provider) NewSource(ref *reference.Spec, architecture string, descriptor *v1.Descriptor) lktspec.ImageSource

NewSource return an ImageSource for a specific ref and architecture in the given cache directory.

func (*Provider) Push

func (p *Provider) Push(name string, withManifest bool) error

Push push an image along with a multi-arch index.

func (*Provider) Remove

func (p *Provider) Remove(name string) error

Remove removes all references pointed to by the provided reference, whether it is an image or an index. If it is not found, it is a no-op. This should be viewed as "Ensure this reference is not in the cache", rather than "Remove this reference from the cache".

func (*Provider) Store

func (p *Provider) Store() (content.Store, error)

Store get content.Store referencing the cache

func (*Provider) ValidateImage

func (p *Provider) ValidateImage(ref *reference.Spec, architecture string) (lktspec.ImageSource, error)

ValidateImage given a reference, validate that it is complete. If not, pull down missing components as necessary. It also calculates the hash of each component.

type ResolvableDescriptor

type ResolvableDescriptor interface {
	Image() (v1.Image, error)
	ImageIndex() (v1.ImageIndex, error)
	Digest() (v1.Hash, error)
}

ResolvableDescriptor an item that can resolve to a v1.Image or a v1.ImageIndex

Jump to

Keyboard shortcuts

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