vmexport

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: Apache-2.0 Imports: 31 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"
	FORMAT_FLAG         = "--format"
	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"
	PORT_FORWARD_FLAG   = "--port-forward"
	LOCAL_PORT_FLAG     = "--local-port"

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

	// Possible output format for volumes
	GZIP_FORMAT = "gzip"
	RAW_FORMAT  = "raw"

	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 SetDefaultPortForwarder added in v1.1.0

func SetDefaultPortForwarder()

SetDefaultPortForwarder sets the port forwarder back to default

func SetHTTPClientCreator

func SetHTTPClientCreator(f HTTPClientCreator)

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

func SetPortForwarder added in v1.1.0

func SetPortForwarder(f PortForwardFunc)

SetPortForwarder allows overriding the default port-forwarder (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 PortForwardFunc added in v1.1.0

type PortForwardFunc func(client kubecli.KubevirtClient, pod k8sv1.Pod, namespace string, ports []string, stopChan, readyChan chan struct{}, portChan chan uint16) error

type VMExportInfo

type VMExportInfo struct {
	ShouldCreate   bool
	Insecure       bool
	KeepVme        bool
	IncludeSecret  bool
	ExportManifest bool
	Decompress     bool
	PortForward    bool
	LocalPort      string
	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