Version: v1.0.0-beta.7 Latest Latest

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

Go to latest
Published: Sep 30, 2019 License: Apache-2.0 Imports: 22 Imported by: 0




View Source
const (
	// IDLen reflects number of symbols in image unique ID.
	IDLen = 64


View Source
var (
	// ErrIsUsed notifies that image is currently being used by someone.
	ErrIsUsed = fmt.Errorf("image is being used")
	// ErrNotFound notifies that image is not found thus cannot be pulled.
	ErrNotFound = fmt.Errorf("image is not found")
	// ErrNotLibrary is used when user tried to get library image metadata but
	// provided non library image reference.
	ErrNotLibrary = fmt.Errorf("not library image")


func NormalizedImageRef

func NormalizedImageRef(imgRef string) string

NormalizedImageRef appends tag 'latest' if the passed ref does not have any tag or digest already. It also trims default docker domain prefix if present.


type Info

type Info struct {
	ID        string             `json:"id"`
	Sha256    string             `json:"sha256"`
	Size      uint64             `json:"size"`
	Path      string             `json:"path"`
	Ref       *Reference         `json:"ref"`
	OciConfig *specs.ImageConfig `json:"ociConfig,omitempty"`
	// contains filtered or unexported fields

Info represents image stored on the host filesystem.

func LibraryInfo

func LibraryInfo(ctx context.Context, ref *Reference, auth *k8s.AuthConfig) (*Info, error)

LibraryInfo queries remote library to get info about the image. If image is not found returns ErrNotFound. For references other than library returns ErrNotLibrary.

func Pull

func Pull(ctx context.Context, location string, ref *Reference, auth *k8s.AuthConfig) (*Info, error)

Pull pulls image referenced by ref and saves it to the passed location.

func (*Info) Borrow

func (i *Info) Borrow(who string)

Borrow notifies that image is used by some container and should not be removed until Return with the same parameters is called. This method is thread-safe to use.

func (*Info) Matches

func (i *Info) Matches(filter *k8s.ImageFilter) bool

Matches tests image against passed filter and returns true if it matches.

func (*Info) Remove

func (i *Info) Remove() error

Remove removes image from the host filesystem. It makes sure no one relies on image file and if this check fails it returns ErrIsUsed error. Local SIF images that were not pulled by CRI are never actually removed.

func (*Info) Return

func (i *Info) Return(who string)

Return notifies that image is no longer used by a container and may be safely removed if no one else needs it anymore. This method is thread-safe to use.

func (*Info) UsedBy

func (i *Info) UsedBy() []string

UsedBy returns list of container ids that use this image.

func (*Info) Verify

func (i *Info) Verify() error

Verify verifies image signatures.

type Reference

type Reference struct {
	// contains filtered or unexported fields

Reference holds parsed content of image reference.

func ParseRef

func ParseRef(imgRef string) (*Reference, error)

ParseRef constructs image reference based on imgRef.

func (*Reference) AddDigests

func (r *Reference) AddDigests(digests []string)

AddDigests adds digests to image reference making sure no duplicates appear.

func (*Reference) AddTags

func (r *Reference) AddTags(tags []string)

AddTags adds tags to image reference making sure no duplicates appear.

func (*Reference) Digests

func (r *Reference) Digests() []string

Digests returns all digests referencing the image.

func (*Reference) MarshalJSON

func (r *Reference) MarshalJSON() ([]byte, error)

MarshalJSON marshals Reference into a valid JSON.

func (*Reference) RemoveDigest

func (r *Reference) RemoveDigest(digest string)

RemoveDigest removes digest from reference.

func (*Reference) RemoveTag

func (r *Reference) RemoveTag(tag string)

RemoveTag removes tag from reference.

func (*Reference) String

func (r *Reference) String() string

String returns first tag or digest found with origin domain as a prefix.

func (*Reference) Tags

func (r *Reference) Tags() []string

Tags returns all tags referencing the image.

func (*Reference) URI

func (r *Reference) URI() string

URI returns uri from which image was originally pulled.

func (*Reference) UnmarshalJSON

func (r *Reference) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals a valid Reference JSON into an object.

Jump to

Keyboard shortcuts

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