Documentation
¶
Index ¶
- func GetHexDigest(imageSpec string) string
- func GetImageVirtualSize(imagePath string) (uint64, error)
- func SplitImageName(imageName string) (string, digest.Digest)
- type Downloader
- type Endpoint
- type FileStore
- func (s *FileStore) BytesUsedBy(path string) (uint64, error)
- func (s *FileStore) FilesystemStats() (*types.FilesystemStats, error)
- func (s *FileStore) GC() error
- func (s *FileStore) GetImagePathDigestAndVirtualSize(ref string) (string, digest.Digest, 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 ¶
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 ¶
FileStore implements Store. For more info on its workings, see docs/images.md
func NewFileStore ¶
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 ¶
BytesUsedBy return disk usage of provided file as seen in store
func (*FileStore) FilesystemStats ¶
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) GetImagePathDigestAndVirtualSize ¶
func (s *FileStore) GetImagePathDigestAndVirtualSize(ref string) (string, digest.Digest, uint64, error)
GetImagePathDigestAndVirtualSize implements GetImagePathDigestAndVirtualSize method of Store interface.
func (*FileStore) ImageStatus ¶
ImageStatus implements ImageStatus method of Store interface.
func (*FileStore) ListImages ¶
ListImages implements ListImages method of ImageStore interface.
func (*FileStore) PullImage ¶
func (s *FileStore) PullImage(ctx context.Context, name string, translator Translator) (string, error)
PullImage implements PullImage method of Store interface.
func (*FileStore) RemoveImage ¶
RemoveImage implements RemoveImage method of Store interface.
func (*FileStore) SetRefGetter ¶
SetRefGetter implements SetRefGetter method of Store interface.
type Store ¶
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 ¶
Translator translates image name to a Endpoint.
type VirtualSizeFunc ¶
VirtualSizeFunc specifies a function that returns the virtual size of the specified QCOW2 image file.