vmexport

package
v1.0.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Available vmexport functions
	CREATE   = "create"
	DELETE   = "delete"
	DOWNLOAD = "download"

	// Available vmexport flags
	OUTPUT_FLAG         = "--output"
	VOLUME_FLAG         = "--volume"
	VM_FLAG             = "--vm"
	SNAPSHOT_FLAG       = "--snapshot"
	INSECURE_FLAG       = "--insecure"
	KEEP_FLAG           = "--keep-vme"
	PVC_FLAG            = "--pvc"
	TTL_FLAG            = "--ttl"
	MANIFEST_FLAG       = "--manifest"
	OUTPUT_FORMAT_FLAG  = "--manifest-output-format"
	SERVICE_URL_FLAG    = "--service-url"
	INCLUDE_SECRET_FLAG = "--include-secret"

	// Possible output format for manifests
	OUTPUT_FORMAT_JSON = "json"
	OUTPUT_FORMAT_YAML = "yaml"

	ACCEPT           = "Accept"
	APPLICATION_YAML = "application/yaml"
	APPLICATION_JSON = "application/json"

	// ErrRequiredFlag serves as error message when a mandatory flag is missing
	ErrRequiredFlag = "need to specify the '%s' flag when using '%s'"
	// ErrIncompatibleFlag serves as error message when an incompatible flag is used
	ErrIncompatibleFlag = "the '%s' flag is incompatible with '%s'"
	// ErrRequiredExportType serves as error message when no export kind is provided
	ErrRequiredExportType = "need to specify export kind when attempting to create a VirtualMachineExport [--pvc|--vm|--snapshot]"
	// ErrIncompatibleExportType serves as error message when an export kind is provided with an incompatible argument
	ErrIncompatibleExportType = "should not specify export kind"
	// ErrIncompatibleExportTypeManifest serves as error message when a PVC kind is defined when getting manifest
	ErrIncompatibleExportTypeManifest = "cannot get manifest for PVC export"
	// ErrInvalidValue ensures that the value provided in a flag is one of the acceptable values
	ErrInvalidValue = "%s is not a valid value, acceptable values are %s"
)

Variables

View Source
var ExportProcessingComplete exportCompleteFunc = waitForVirtualMachineExport

ExportProcessingComplete is used to store the function to wait for the export object to be ready. Useful for unit tests.

Functions

func CreateVirtualMachineExport

func CreateVirtualMachineExport(client kubecli.KubevirtClient, vmeInfo *VMExportInfo) error

CreateVirtualMachineExport serves as a wrapper to create the virtualMachineExport object and, if needed, do error handling

func DeleteVirtualMachineExport

func DeleteVirtualMachineExport(client kubecli.KubevirtClient, vmeInfo *VMExportInfo) error

DeleteVirtualMachineExport serves as a wrapper to delete the virtualMachineExport object

func DownloadVirtualMachineExport

func DownloadVirtualMachineExport(client kubecli.KubevirtClient, vmeInfo *VMExportInfo) error

DownloadVirtualMachineExport handles the process of downloading the requested volume from a VirtualMachineExport object

func GetManifestUrlsFromVirtualMachineExport added in v0.59.1

func GetManifestUrlsFromVirtualMachineExport(vmexport *exportv1.VirtualMachineExport, vmeInfo *VMExportInfo) (map[exportv1.ExportManifestType]string, error)

GetManifestUrlsFromVirtualMachineExport retrieves the manifest URLs from VirtualMachineExport status

func GetUrlFromVirtualMachineExport

func GetUrlFromVirtualMachineExport(vmexport *exportv1.VirtualMachineExport, vmeInfo *VMExportInfo) (string, error)

GetUrlFromVirtualMachineExport inspects the VirtualMachineExport status to fetch the extected URL

func NewVirtualMachineExportCommand

func NewVirtualMachineExportCommand(clientConfig clientcmd.ClientConfig) *cobra.Command

NewVirtualMachineExportCommand returns a cobra.Command to handle the export process

func SetDefaultHTTPClientCreator

func SetDefaultHTTPClientCreator()

SetDefaultHTTPClientCreator sets the http client creator back to default

func SetHTTPClientCreator

func SetHTTPClientCreator(f HTTPClientCreator)

SetHTTPClientCreator allows overriding the default http client (useful for unit testing)

Types

type HTTPClientCreator

type HTTPClientCreator func(*http.Transport, bool) *http.Client

type HandleHTTPRequestFunc added in v0.59.1

type HandleHTTPRequestFunc func(client kubecli.KubevirtClient, vmexport *exportv1.VirtualMachineExport, downloadUrl string, insecure bool, exportURL string, headers map[string]string) (*http.Response, error)

HandleHTTPRequestFunc function used to handle http requests

var HandleHTTPRequest HandleHTTPRequestFunc = handleHTTPGetRequest

instance of function used to handle http requests

type VMExportInfo

type VMExportInfo struct {
	ShouldCreate   bool
	Insecure       bool
	KeepVme        bool
	IncludeSecret  bool
	ExportManifest bool
	OutputFile     string
	OutputWriter   io.Writer
	VolumeName     string
	Namespace      string
	Name           string
	OutputFormat   string
	ServiceURL     string
	ExportSource   k8sv1.TypedLocalObjectReference
	TTL            metav1.Duration
}

Jump to

Keyboard shortcuts

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