Documentation ¶
Overview ¶
Package image exposes methods and abstractions for extracting and managing virtual machine images. Amongst other things this involves securing that the images don't reference external files as backing store.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Downloader ¶
Downloader is a function capable of downloading an image to an imageFile. The downloader writes the image file to the imageFile supplied, and returns an error if all retries etc. fails.
func DownloadImage ¶
func DownloadImage(url string) Downloader
DownloadImage returns a Downloader that will download the image from the given url. This will attempt multiple retries if necessary.
If there is a non-200 response this will return a MalformedPayloadError.
type Instance ¶
type Instance struct {
// contains filtered or unexported fields
}
Instance represents an instance of an image.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager loads and tracks images.
func NewManager ¶
func NewManager(imageFolder string, gc gc.ResourceTracker, log *logrus.Entry, sentry *raven.Client) (*Manager, error)
NewManager creates a new image manager using the imageFolder for storing images and instances of images.
func (*Manager) Instance ¶
func (m *Manager) Instance(imageID string, download Downloader) (*Instance, error)
Instance will return an Instance of the image with imageID. If no such image exists in the cache, download() will be called to download it to a temporary filename.
This method will insert the downloaded image into the cache, and ensures that if won't be downloaded twice, if another invocation already is downloading an image with the same imageID.
It is the responsibility of the caller to make sure that imageID is a string that uniquely identifies the image. Sane patterns includes "url:<url>", or "taskId:<taskId>/<runId>/<artifact>". It also the callers responsibility to enforce any sort of access control.
type MutableImage ¶
type MutableImage struct {
// contains filtered or unexported fields
}
MutableImage is an vm.MutableImage implementation that keeps the image in a single folder. This can be used for testing images and building new images.
func NewMutableImage ¶
NewMutableImage creates a new blank MutableImage of given size in GiB, and using the given machine configuration.
This is used when building new images.
func NewMutableImageFromFile ¶
func NewMutableImageFromFile(imageFile, imageFolder string) (*MutableImage, error)
NewMutableImageFromFile creates a mutable image from an existing compressed image tar archieve.
func (*MutableImage) DiskFile ¶
func (img *MutableImage) DiskFile() string
DiskFile returns path to disk file to use in QEMU. This also marks the image as being in-use.
func (*MutableImage) Dispose ¶
func (img *MutableImage) Dispose()
Dispose will delete all resources hold by the MutableImage
func (*MutableImage) Format ¶
func (img *MutableImage) Format() string
Format returns the image format: 'raw'.
func (*MutableImage) Machine ¶
func (img *MutableImage) Machine() vm.Machine
Machine returns the vm.Machine definition of the virtual machine.
func (*MutableImage) Package ¶
func (img *MutableImage) Package(targetFile string) error
Package will write an zstd compressed tar archieve of the image to targetFile. This method cannot be called the image is in-use.
func (*MutableImage) Release ¶
func (img *MutableImage) Release()
Release marks the MutableImage as no longer in use. This allows Package() or Dispose() to be called.