Documentation ¶
Index ¶
- Constants
- Variables
- func CleanDir(dest string) error
- func CopyData(dso *DataStreamOptions) error
- func DefaultSaveStream(stream io.ReadCloser, dest, imageSize string) (int64, error)
- func MoveFile(src, dst string) 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
- type DataContext
- type DataStream
- type DataStreamInterface
- type DataStreamOptions
Constants ¶
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 ¶
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
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 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, diskImageFileName, dataPath, scratchPath, imageSize string) (int64, error)
SaveStream reads from a stream and saves data to dest
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().
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.