importer

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2019 License: Apache-2.0 Imports: 28 Imported by: 6

Documentation

Index

Constants

View Source
const (

	//ContainerDiskImageDir - Expected disk image location in container image as described in
	//https://github.com/kubevirt/kubevirt/blob/master/docs/container-register-disks.md
	ContainerDiskImageDir = "disk"
)

Variables

View Source
var ErrRequiresScratchSpace = fmt.Errorf("Scratch space required and none found")

ErrRequiresScratchSpace indicates that we require scratch space.

Functions

func CleanDir added in v1.7.0

func CleanDir(dest string) error

CleanDir cleans the contents of a directory including its sub directories, but does NOT remove the directory itself.

func CopyData added in v1.4.0

func CopyData(dso *DataStreamOptions) error

CopyData copies the source endpoint (vm image) to the provided destination path.

func DefaultSaveStream added in v1.7.0

func DefaultSaveStream(stream io.ReadCloser, dest, imageSize string) (int64, error)

DefaultSaveStream reads from a stream and saves data to dest using the default disk image/data/scratch paths

func MoveFile added in v1.6.0

func MoveFile(src, dst string) error

MoveFile - moves file

func ParseEndpoint

func ParseEndpoint(endpt string) (*url.URL, error)

ParseEndpoint parses the required endpoint and return the url struct.

func ResizeImage added in v1.4.0

func ResizeImage(dest, imageSize string, totalTargetSpace int64) error

ResizeImage resizes the images to match the requested size. Sometimes provisioners misbehave and the available space is not the same as the requested space. For those situations we compare the available space to the requested space and use the smallest of the two values.

func SaveStream

func SaveStream(stream io.ReadCloser, dest string, diskImageFileName, dataPath, scratchPath, imageSize string) (int64, error)

SaveStream reads from a stream and saves data to dest

func StreamDataToFile

func StreamDataToFile(dataReader io.Reader, filePath string) error

StreamDataToFile provides a function to stream the specified io.Reader to the specified local file

Types

type DataContext added in v1.6.0

type DataContext interface {
	Cleanup() error
}

DataContext - allows cleanup of temporary data created by specific import method

type DataStream

type DataStream struct {
	*DataStreamOptions

	Readers []reader

	Size int64
	// contains filtered or unexported fields
}

DataStream implements the ReadCloser interface

func NewDataStream

func NewDataStream(dso *DataStreamOptions) (*DataStream, error)

NewDataStream returns a DataStream object after validating the endpoint and constructing the reader/closer chain. Note: the caller must close the `Readers` in reverse order. See Close().

func (*DataStream) Close

func (d *DataStream) Close() error

Close all readers.

func (*DataStream) Read

func (d *DataStream) Read(buf []byte) (int, error)

Read from top-most reader. Note: ReadFull is needed since there may be intermediate, smaller multi-readers in the reader stack, and we need to be able to fill buf.

type DataStreamInterface

type DataStreamInterface interface {
	Read(p []byte) (int, error)
	Close() error
	// contains filtered or unexported methods
}

DataStreamInterface provides our interface definition required to fulfill a DataStream

type DataStreamOptions added in v1.4.0

type DataStreamOptions struct {
	// Dest is the destination path of the contents of the stream.
	Dest string
	// DataDir is the destination path where data is stored
	DataDir string
	// Endpoint is the endpoint to get the data from for various Sources.
	Endpoint string
	// AccessKey is the access key for the endpoint, can be blank. This needs to be a base64 encoded string.
	AccessKey string
	// SecKey is the security key needed for the endpoint, can be blank. This needs to be a base64 encoded string.
	SecKey string
	// Source is the source type of the data.
	Source string
	// ContentType is the content type of the data.
	ContentType string
	// ImageSize is the size we want the resulting image to be.
	ImageSize string
	// Available space is the available space before downloading the image
	AvailableDestSpace int64
	// CertDir is a directory containing tls certs
	CertDir string
	// InsecureTLS is it okay to skip TLS verification
	InsecureTLS bool
	// ScratchDataDir is the path to the scratch space inside the container.
	ScratchDataDir string
}

DataStreamOptions contains all the values needed for importing from a DataStream.

Jump to

Keyboard shortcuts

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