importer

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: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 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) (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

func ValidateSpaceConstraint added in v1.4.0

func ValidateSpaceConstraint(qcow2Image string, destDir string) (bool, error)

ValidateSpaceConstraint - validates wheather there is enough space in PVC for both qcow2 image and converted raw image Assumes it is possible to retrieve info from qcow2 file by means of qemu-img utility Returns failure if either of the following happens 1. info cannot be retrieved from qcow2 file 2. Either ActualSize or VirtualSize are 0 - not specified 3. ActualSize and VirtualSize together exceed available PVC Space

Types

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
	// 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
	AvailableSpace int64
	// CertDir is a directory containing tls certs
	CertDir 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