vmexport

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: Apache-2.0 Imports: 32 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"
	DELETE_FLAG         = "--delete-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"
	RETRY_FLAG          = "--retry"

	// 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 GetHTTPClientFn = GetHTTPClient

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

View Source
var HandleHTTPGetRequestFn = HandleHTTPGetRequest

HandleHTTPGetRequestFn allows overriding the default http GET request handler (useful for unit testing)

View Source
var RunPortForwardFn = RunPortForward

RunPortForwardFn allows overriding the default port-forwarder (useful for unit testing)

View Source
var WaitForVirtualMachineExportFn = WaitForVirtualMachineExport

WaitForVirtualMachineExportFn allows overriding the function to wait for the export object to be ready (useful for unit testing)

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 GetHTTPClient added in v1.4.0

func GetHTTPClient(transport *http.Transport, insecure bool) *http.Client

GetHTTPClient assigns the default, non-mocked HTTP client

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 HandleHTTPGetRequest added in v1.4.0

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

HandleHTTPGetRequest generates the GET request with proper certificate handling

func NewVirtualMachineExportCommand

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

NewVirtualMachineExportCommand returns a cobra.Command to handle the export process

func RunPortForward added in v1.4.0

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

RunPortForward is the actual function that runs the port-forward. Meant to be run concurrently

func WaitForVirtualMachineExport added in v1.4.0

func WaitForVirtualMachineExport(client kubecli.KubevirtClient, vmeInfo *VMExportInfo, interval, timeout time.Duration) error

WaitForVirtualMachineExport waits for the VirtualMachineExport status and external links to be ready

Types

type VMExportInfo

type VMExportInfo struct {
	ShouldCreate    bool
	Insecure        bool
	KeepVme         bool
	DeleteVme       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
	DownloadRetries int
}

Jump to

Keyboard shortcuts

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