image

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHexDigest added in v1.0.3

func GetHexDigest(imageSpec string) string

GetHexDigest returns the hex digest contained in imageSpec, if any, or an empty string if imageSpec doesn't have the spec.

func GetImageVirtualSize

func GetImageVirtualSize(imagePath string) (uint64, error)

GetImageVirtualSize returns the virtual size of the specified QCOW2 image

func SplitImageName added in v1.4.0

func SplitImageName(imageName string) (string, digest.Digest)

SplitImageName parses image nmae and returns the name sans tag and the digest, if any.

Types

type Downloader

type Downloader interface {
	// DownloadFile downloads the specified file
	DownloadFile(ctx context.Context, endpoint Endpoint, w io.Writer) error
}

Downloader is an interface for downloading files from web

func NewDownloader

func NewDownloader(protocol string) Downloader

NewDownloader returns the default downloader for 'protocol'. The default downloader downloads a file via an URL constructed as 'protocol://location' and saves it in temporary file in default system directory for temporary files

type Endpoint

type Endpoint struct {
	// URL is the image URL. If protocol is omitted, the
	// configured default one is used.
	URL string

	// MaxRedirects is the maximum number of redirects that downloader is allowed to follow. -1 for stdlib default (fails on request #10)
	MaxRedirects int

	// TLS is the TLS config
	TLS *TLSConfig

	// Timeout specifies a time limit for http(s) download request. <= 0 is no timeout (default)
	Timeout time.Duration

	// Proxy is the proxy server to use. Default = use proxy from HTTP_PROXY environment variable
	Proxy string

	// Transport profile name for this endpoint. Provided for logging/debugging
	ProfileName string
}

Endpoint contains all the endpoint parameters needed to download a file

type FileStore added in v1.0.0

type FileStore struct {
	sync.Mutex
	// contains filtered or unexported fields
}

FileStore implements Store. For more info on its workings, see docs/images.md

func NewFileStore added in v1.0.0

func NewFileStore(dir string, downloader Downloader, vsizeFunc VirtualSizeFunc) *FileStore

NewFileStore creates a new FileStore that will be using the specified dir to store the images, image downloader and a function for getting virtual size of the image. If vsizeFunc is nil, the default GetImageVirtualSize function will be used.

func (*FileStore) BytesUsedBy added in v1.4.0

func (s *FileStore) BytesUsedBy(path string) (uint64, error)

BytesUsedBy return disk usage of provided file as seen in store

func (*FileStore) FilesystemStats added in v1.2.0

func (s *FileStore) FilesystemStats() (*types.FilesystemStats, error)

FilesystemStats returns disk space and inode usage info for this store. TODO: instead of returning data from filesystem we should retrieve from metadata store sizes of images and sum them, or even retrieve precalculated sum. That's because same filesystem could be used by other things than images.

func (*FileStore) GC added in v1.0.0

func (s *FileStore) GC() error

GC implements GC method of Store interface.

func (*FileStore) GetImagePathDigestAndVirtualSize added in v1.4.0

func (s *FileStore) GetImagePathDigestAndVirtualSize(ref string) (string, digest.Digest, uint64, error)

GetImagePathDigestAndVirtualSize implements GetImagePathDigestAndVirtualSize method of Store interface.

func (*FileStore) ImageStatus added in v1.0.0

func (s *FileStore) ImageStatus(name string) (*Image, error)

ImageStatus implements ImageStatus method of Store interface.

func (*FileStore) ListImages added in v1.0.0

func (s *FileStore) ListImages(filter string) ([]*Image, error)

ListImages implements ListImages method of ImageStore interface.

func (*FileStore) PullImage added in v1.0.0

func (s *FileStore) PullImage(ctx context.Context, name string, translator Translator) (string, error)

PullImage implements PullImage method of Store interface.

func (*FileStore) RemoveImage added in v1.0.0

func (s *FileStore) RemoveImage(name string) error

RemoveImage implements RemoveImage method of Store interface.

func (*FileStore) SetRefGetter added in v1.0.0

func (s *FileStore) SetRefGetter(imageRefGetter RefGetter)

SetRefGetter implements SetRefGetter method of Store interface.

type Image

type Image struct {
	Digest string
	Name   string
	Path   string
	Size   uint64
}

Image describes an image.

type RefGetter added in v1.0.0

type RefGetter func() (map[string]bool, error)

RefGetter is a function that returns the list of images that are currently in use.

type Store added in v1.0.0

type Store interface {
	// ListImage returns the list of images in the store.
	// If filter is specified, the list will only contain the
	// image with the same name as the value of 'filter',
	// or no images at all if there are no such images.
	ListImages(filter string) ([]*Image, error)

	// ImageStatus returns the description of the specified image.
	// If the image doesn't exist, no error is returned, just
	// nil instead of an image.
	ImageStatus(name string) (*Image, error)

	// PullImage pulls the image using specified image name translation
	// function.
	PullImage(ctx context.Context, name string, translator Translator) (string, error)

	// RemoveImage removes the specified image.
	RemoveImage(name string) error

	// GC removes all unused or partially downloaded images.
	GC() error

	// GetImagePathDigestAndVirtualSize returns the path to image
	// data, the digest and the virtual size for the specified
	// image. It accepts an image reference or a digest.
	GetImagePathDigestAndVirtualSize(ref string) (string, digest.Digest, uint64, error)

	// SetRefGetter sets a function that will be used to determine
	// the set of images that are currently in use.
	SetRefGetter(imageRefGetter RefGetter)

	// FilesystemStats returns disk space and inode usage info for this store.
	FilesystemStats() (*types.FilesystemStats, error)

	// BytesUsedBy returns disk usage of the file in this store.
	BytesUsedBy(path string) (uint64, error)
}

Store is an interface for the image store.

type TLSCertificate

type TLSCertificate struct {
	// Certificate is the x509 certificate
	Certificate *x509.Certificate

	// PrivateKey is the private key needed for certificate-based client authentication
	PrivateKey crypto.PrivateKey
}

TLSCertificate is a x509 certificate with optional private key

type TLSConfig

type TLSConfig struct {
	// Certificates to use (both CA and for client authentication)
	Certificates []TLSCertificate

	// ServerName is needed when connecting to domain other that certificate was issued for
	ServerName string

	// Insecure skips certificate verification
	Insecure bool
}

TLSConfig has the TLS transport parameters

type Translator added in v1.0.0

type Translator func(context.Context, string) Endpoint

Translator translates image name to a Endpoint.

type VirtualSizeFunc

type VirtualSizeFunc func(string) (uint64, error)

VirtualSizeFunc specifies a function that returns the virtual size of the specified QCOW2 image file.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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