Documentation
¶
Index ¶
- func GetImageVirtualSize(imagePath string) (uint64, error)
- type Downloader
- type Endpoint
- type Image
- type ImageFileStore
- func (s *ImageFileStore) GC() error
- func (s *ImageFileStore) GetImagePathAndVirtualSize(ref string) (string, uint64, error)
- func (s *ImageFileStore) ImageStatus(name string) (*Image, error)
- func (s *ImageFileStore) ListImages(filter string) ([]*Image, error)
- func (s *ImageFileStore) PullImage(ctx context.Context, name string, translator ImageTranslator) (string, error)
- func (s *ImageFileStore) RemoveImage(name string) error
- func (s *ImageFileStore) SetRefGetter(imageRefGetter ImageRefGetter)
- type ImageRefGetter
- type ImageStore
- type ImageTranslator
- type TLSCertificate
- type TLSConfig
- type VirtualSizeFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ImageFileStore ¶
ImageFileStore implements ImageStore. For more info on its workings, see docs/images.md
func NewImageFileStore ¶
func NewImageFileStore(dir string, downloader Downloader, vsizeFunc VirtualSizeFunc) *ImageFileStore
NewImageFileStore creates a new ImageFileStore 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 (*ImageFileStore) GC ¶
func (s *ImageFileStore) GC() error
GC implements GC method of ImageStore interface
func (*ImageFileStore) GetImagePathAndVirtualSize ¶
func (s *ImageFileStore) GetImagePathAndVirtualSize(ref string) (string, uint64, error)
GetImagePathAndVirtualSize implements GC method of GetImagePathAndVirtualSize interface
func (*ImageFileStore) ImageStatus ¶
func (s *ImageFileStore) ImageStatus(name string) (*Image, error)
ImageStatus implements ImageStatus method of ImageStore interface
func (*ImageFileStore) ListImages ¶
func (s *ImageFileStore) ListImages(filter string) ([]*Image, error)
ListImages implements ListImages method of ImageStore interface
func (*ImageFileStore) PullImage ¶
func (s *ImageFileStore) PullImage(ctx context.Context, name string, translator ImageTranslator) (string, error)
PullImage implements PullImage method of ImageStore interface
func (*ImageFileStore) RemoveImage ¶
func (s *ImageFileStore) RemoveImage(name string) error
RemoveImage implements RemoveImage method of ImageStore interface
func (*ImageFileStore) SetRefGetter ¶
func (s *ImageFileStore) SetRefGetter(imageRefGetter ImageRefGetter)
SetRefGetter implements SetRefGetter method of ImageStore interface
type ImageRefGetter ¶
ImageRefGetter is a function that returns the list of images that are currently in use
type ImageStore ¶
type ImageStore 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 ImageTranslator) (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 ImageRefGetter)
}
ImageStore is an interface for the image store
type ImageTranslator ¶
ImageTranslator translates image name to a Endpoint
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 VirtualSizeFunc ¶
VirtualSizeFunc specifies a function that returns the virtual size of the specified QCOW2 image file