image

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ExtImg is a constant for the .img extenstion
	ExtImg = ".img"
	// ExtIso is a constant for the .iso extenstion
	ExtIso = ".iso"
	// ExtGz is a constant for the .gz extenstion
	ExtGz = ".gz"
	// ExtQcow2 is a constant for the .qcow2 extenstion
	ExtQcow2 = ".qcow2"
	// ExtTar is a constant for the .tar extenstion
	ExtTar = ".tar"
	// ExtXz is a constant for the .xz extenstion
	ExtXz = ".xz"
	// ExtTarXz is a constant for the .tar.xz extenstion
	ExtTarXz = ExtTar + ExtXz
	// ExtTarGz is a constant for the .tar.gz extenstion
	ExtTarGz = ExtTar + ExtGz
)
View Source
const MaxExpectedHdrSize = 512

MaxExpectedHdrSize defines the Size of buffer used to read file headers. Note: this is the size of tar's header. If a larger number is used the tar unarchive operation

creates the destination file too large, by the difference between this const and 512.

Variables

View Source
var (

	// SkopeoInterface the skopeo operations interface
	SkopeoInterface = NewSkopeoOperations()
)

Functions

func ConvertQcow2ToRaw

func ConvertQcow2ToRaw(src, dest string) error

ConvertQcow2ToRaw is a wrapper for qemu-img convert which takes a qcow2 file (specified by src) and converts it to a raw image (written to the provided dest file)

func ConvertQcow2ToRawStream

func ConvertQcow2ToRawStream(url *url.URL, dest string) error

ConvertQcow2ToRawStream converts an http accessible qcow2 image to raw format without locally caching the qcow2 image

func CopyRegistryImage added in v1.4.0

func CopyRegistryImage(url, dest, destFile, accessKey, secKey, certDir string) error

CopyRegistryImage download image from registry with skopeo

func CreateBlankImage added in v1.4.0

func CreateBlankImage(dest string, size resource.Quantity) error

CreateBlankImage creates empty raw image

func Validate

func Validate(image, format string, availableSize int64) error

Validate does basic validation of a qemu image

Types

type Header struct {
	Format string

	SizeOff int // in bytes
	SizeLen int // in bytes
	// contains filtered or unexported fields
}

Header represents our parameters for a file format header

func (Header) Match

func (h Header) Match(b []byte) bool

Match performs a check to see if the provided byte slice matches the bytes in our header data

func (Header) Size

func (h Header) Size(b []byte) (int64, error)

Size uses the Header receiver offset and length fields to extract, from the passed-in file header slice (b), the size of the original file. It is not guaranteed that the header is known to cdi and thus 0 may be returned as the size.

type Headers

type Headers map[string]Header

Headers provides a map for header info, key is file format, eg. "gz" or "tar", value is metadata describing the layout for this hdr

func CopyKnownHdrs

func CopyKnownHdrs() Headers

CopyKnownHdrs performs a simple map copy since := assignment copies the reference to the map, not contents.

type ImgInfo added in v1.4.0

type ImgInfo struct {
	// Format contains the format of the image
	Format string `json:"format"`
	// BackingFile is the file name of the backing file
	BackingFile string `json:"backing-filename"`
	// VirtualSize is the disk size of the image which will be read by vm
	VirtualSize int64 `json:"virtual-size"`
	// ActualSize is the size of the qcow2 image
	ActualSize int64 `json:"actual-size"`
}

ImgInfo contains the virtual image information.

type QEMUOperations

type QEMUOperations interface {
	ConvertQcow2ToRaw(string, string) error
	ConvertQcow2ToRawStream(*url.URL, string) error
	Resize(string, resource.Quantity) error
	Info(string) (*ImgInfo, error)
	Validate(string, string, int64) error
	CreateBlankImage(dest string, size resource.Quantity) error
}

QEMUOperations defines the interface for executing qemu subprocesses

func NewQEMUOperations

func NewQEMUOperations() QEMUOperations

NewQEMUOperations returns the default implementation of QEMUOperations

type SkopeoOperations added in v1.4.0

type SkopeoOperations interface {
	CopyImage(string, string, string, string, string) error
}

SkopeoOperations defines the interface for executing skopeo subprocesses

func NewSkopeoOperations added in v1.4.0

func NewSkopeoOperations() SkopeoOperations

NewSkopeoOperations returns the default implementation of SkopeoOperations

Jump to

Keyboard shortcuts

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