Documentation
¶
Index ¶
- func GetHexDigest(imageSpec string) string
- func GetImageVirtualSize(imagePath string) (uint64, error)
- func StripTags(imageName string) string
- type Downloader
- type Endpoint
- type FileStore
- func (s *FileStore) GC() error
- func (s *FileStore) GetImagePathAndVirtualSize(ref string) (string, uint64, error)
- func (s *FileStore) ImageStatus(name string) (*Image, error)
- func (s *FileStore) ListImages(filter string) ([]*Image, error)
- func (s *FileStore) PullImage(ctx context.Context, name string, translator Translator) (string, error)
- func (s *FileStore) RemoveImage(name string) error
- func (s *FileStore) SetRefGetter(imageRefGetter RefGetter)
- type Image
- type RefGetter
- type Store
- type TLSCertificate
- type TLSConfig
- type Translator
- type VirtualSizeFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetHexDigest ¶ added in v1.0.2
GetHexDigest returns the hex digest contained in imageSpec, if any, or an empty string if imageSpec doesn't have the spec.
func GetImageVirtualSize ¶
GetImageVirtualSize returns the virtual size of the specified QCOW2 image
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
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) GetImagePathAndVirtualSize ¶ added in v1.0.0
GetImagePathAndVirtualSize implements GC method of Store interface.
func (*FileStore) ImageStatus ¶ added in v1.0.0
ImageStatus implements ImageStatus method of Store interface.
func (*FileStore) ListImages ¶ added in v1.0.0
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
RemoveImage implements RemoveImage method of Store interface.
func (*FileStore) SetRefGetter ¶ added in v1.0.0
SetRefGetter implements SetRefGetter method of Store interface.
type RefGetter ¶ added in v1.0.0
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
// GetImagePathAndVirtualSize returns the path to image data
// and virtual size for the specified image. It accepts
// an image reference or a digest.
GetImagePathAndVirtualSize(ref string) (string, uint64, error)
// SetRefGetter sets a function that will be used to determine
// the set of images that are currently in use.
SetRefGetter(imageRefGetter RefGetter)
}
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
Translator translates image name to a Endpoint.
type VirtualSizeFunc ¶
VirtualSizeFunc specifies a function that returns the virtual size of the specified QCOW2 image file.