Documentation ¶
Index ¶
- func CopyData(dso *DataStreamOptions) error
- func ParseEndpoint(endpt string) (*url.URL, error)
- func ResizeImage(dest, imageSize string, totalTargetSpace int64) error
- func SaveStream(stream io.ReadCloser, dest string) (int64, error)
- func StreamDataToFile(dataReader io.Reader, filePath string) error
- func ValidateSpaceConstraint(qcow2Image string, destDir string) (bool, error)
- type DataStream
- type DataStreamInterface
- type DataStreamOptions
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 ¶
ParseEndpoint parses the required endpoint and return the url struct.
func ResizeImage ¶ added in v1.4.0
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 ¶
StreamDataToFile provides a function to stream the specified io.Reader to the specified local file
func ValidateSpaceConstraint ¶ added in v1.4.0
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().
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 }
DataStreamOptions contains all the values needed for importing from a DataStream.