Documentation
¶
Index ¶
- Constants
- Variables
- func BytesToResource(b int64) *resource.Quantity
- func CalculateReservedForSnapshotPerStorageClass(ctx context.Context, k8sClient ctrlclient.Client, logger logr.Logger, ...) ([]vmopv1.VirtualMachineSnapshotStorageStatusRequested, error)
- func GetDefaultEncryptionClassForNamespace(ctx context.Context, k8sClient ctrlclient.Client, namespace string) (byokv1.EncryptionClass, error)
- func GetPVCZoneConstraints(storageClasses map[string]storagev1.StorageClass, ...) (sets.Set[string], error)
- func GetStoragePolicyID(obj storagev1.StorageClass) (string, error)
- func GetStoragePolicyObjectName(profileID string) string
- func GetVirtualMachineReconcilePriority(ctx context.Context, _ EventType, newObj, _ client.Object, defaultPriority int) int
- func HasCAPILabels(labels map[string]string) bool
- func HasVMOperatorLabels(labels map[string]string) bool
- func IsEncryptedStorageClass(ctx context.Context, k8sClient ctrlclient.Client, name string) (bool, string, error)
- func IsEncryptedStorageProfile(ctx context.Context, k8sClient ctrlclient.Client, profileID string) (bool, error)
- func MarkEncryptedStorageClass(ctx context.Context, k8sClient ctrlclient.Client, ...) error
- func MustSyncGVKToObject(obj runtime.Object, scheme *runtime.Scheme)
- func PatchSnapshotSuccessStatus(ctx context.Context, logger logr.Logger, k8sClient ctrlclient.Client, ...) error
- func RemoveVMOperatorLabels(labels map[string]string) map[string]string
- func SetStoragePolicyID(obj *storagev1.StorageClass, id string)
- func SyncGVKToObject(obj runtime.Object, scheme *runtime.Scheme) error
- type EnqueueRequestForObject
- type ErrMissingParameter
- type EventType
- type GetPriorityFn
- type TypedEnqueueRequestForObject
- func (e *TypedEnqueueRequestForObject[T]) Create(ctx context.Context, evt event.TypedCreateEvent[T], ...)
- func (e *TypedEnqueueRequestForObject[T]) Delete(ctx context.Context, evt event.TypedDeleteEvent[T], ...)
- func (e *TypedEnqueueRequestForObject[T]) Generic(ctx context.Context, evt event.TypedGenericEvent[T], ...)
- func (e *TypedEnqueueRequestForObject[T]) Update(ctx context.Context, evt event.TypedUpdateEvent[T], ...)
- type TypedResourceVersionChangedPredicate
Constants ¶
const ( // DefaultEncryptionClassLabelName is the name of the label that identifies // the default EncryptionClass in a given namespace. DefaultEncryptionClassLabelName = "encryption.vmware.com/default" // DefaultEncryptionClassLabelValue is the value of the label that // identifies the default EncryptionClass in a given namespace. DefaultEncryptionClassLabelValue = "true" )
const ( // CAPWClusterRoleLabelKey is the key for the label applied to a VM that was // created by CAPW. CAPWClusterRoleLabelKey = "capw.vmware.com/cluster.role" //nolint:gosec // CAPVClusterRoleLabelKey is the key for the label applied to a VM that was // created by CAPV. CAPVClusterRoleLabelKey = "capv.vmware.com/cluster.role" // VMOperatorLabelDomain is the domain for VM Operator managed labels. VMOperatorLabelDomain = "vmoperator.vmware.com" )
const ( // PriorityGeneric is the priority for a generic event. PriorityGeneric = iota + 1 // PriorityUpdate is the priority for an update event. PriorityUpdate // PriorityDelete is the priority for a delete event. PriorityDelete // PriorityCreate is the priority for a create event. PriorityCreate )
const ( // PriorityVirtualMachineCreating is the reconcile priority for a VM that // does not have a Created condition set to True. PriorityVirtualMachineCreating int = 100 - iota // PriorityVirtualMachinePowerStateChange is the reconcile priority for a VM // that has a desired power state not equal to its observed power state. PriorityVirtualMachinePowerStateChange // PriorityVirtualMachineWaitingForIP is the reconcile priority for a VM // that is powered on, should have an IP, but does not. PriorityVirtualMachineWaitingForIP // PriorityVirtualMachineDeleting is the reconcile priority for a VM that // is being deleted. PriorityVirtualMachineDeleting // PriorityVirtualMachineWaitingForDiskPromo is the reconcile priority for a // VM that is waiting on disk promotion. PriorityVirtualMachineWaitingForDiskPromo )
Variables ¶
var ( // ErrNoDefaultEncryptionClass is returned by the // GetDefaultEncryptionClassForNamespace method if there are no // EncryptionClasses in a given namespace marked as default. ErrNoDefaultEncryptionClass = fmt.Errorf( "no EncryptionClass resource has the label %q: %q", DefaultEncryptionClassLabelName, DefaultEncryptionClassLabelValue) // ErrMultipleDefaultEncryptionClasses is returned by the // GetDefaultEncryptionClassForNamespace method if more than one // EncryptionClass in a given namespace are marked as default. ErrMultipleDefaultEncryptionClasses = fmt.Errorf( "multiple EncryptionClass resources have the label %q: %q", DefaultEncryptionClassLabelName, DefaultEncryptionClassLabelValue) )
Functions ¶
func BytesToResource ¶ added in v1.10.0
BytesToResource returns the resource.Quantity value for the specified number of bytes.
func CalculateReservedForSnapshotPerStorageClass ¶ added in v1.10.0
func CalculateReservedForSnapshotPerStorageClass( ctx context.Context, k8sClient ctrlclient.Client, logger logr.Logger, vmSnapshot vmopv1.VirtualMachineSnapshot) ([]vmopv1.VirtualMachineSnapshotStorageStatusRequested, error)
CalculateReservedForSnapshotPerStorageClass calculates the reserved capacity for a snapshot. And return the requested capacity categorized by each storage class. 1. Space required for classic disks. 2. Space required for VM's memory. 3. Space required for each PVC.
func GetDefaultEncryptionClassForNamespace ¶ added in v1.9.0
func GetDefaultEncryptionClassForNamespace( ctx context.Context, k8sClient ctrlclient.Client, namespace string) (byokv1.EncryptionClass, error)
GetDefaultEncryptionClassForNamespace returns the default EncryptionClass for the provided namespace.
func GetPVCZoneConstraints ¶ added in v1.9.0
func GetPVCZoneConstraints( storageClasses map[string]storagev1.StorageClass, pvcs []corev1.PersistentVolumeClaim) (sets.Set[string], error)
func GetStoragePolicyID ¶ added in v1.9.0
func GetStoragePolicyID(obj storagev1.StorageClass) (string, error)
GetStoragePolicyID returns the storage policy ID for a given StorageClass. If no ID is found, an error is returned.
func GetStoragePolicyObjectName ¶ added in v1.10.0
GetStoragePolicyObjectName returns the expected name of a StoragePolicy object based on the policy's profile ID.
func GetVirtualMachineReconcilePriority ¶ added in v1.10.0
func GetVirtualMachineReconcilePriority( ctx context.Context, _ EventType, newObj, _ client.Object, defaultPriority int) int
GetVirtualMachineReconcilePriority returns the reconcile priority for a VirtualMachine.
func HasCAPILabels ¶ added in v1.8.6
HasCAPILabels returns true if the VM has a label indicating it was created by Cluster API such as CAPW or CAPV.
func HasVMOperatorLabels ¶ added in v1.10.0
HasVMOperatorLabels returns true if the given labels map has a label key containing the "vmoperator.vmware.com" domain.
func IsEncryptedStorageClass ¶ added in v1.9.0
func IsEncryptedStorageClass( ctx context.Context, k8sClient ctrlclient.Client, name string) (bool, string, error)
IsEncryptedStorageClass returns true if the provided StorageClass name was marked as encrypted. If encryption is supported, the StorageClass's profile ID is also returned.
func IsEncryptedStorageProfile ¶ added in v1.9.0
func IsEncryptedStorageProfile( ctx context.Context, k8sClient ctrlclient.Client, profileID string) (bool, error)
IsEncryptedStorageProfile returns true if the provided storage profile ID was marked as encrypted.
func MarkEncryptedStorageClass ¶ added in v1.9.0
func MarkEncryptedStorageClass( ctx context.Context, k8sClient ctrlclient.Client, storageClass storagev1.StorageClass, encrypted bool) error
MarkEncryptedStorageClass records the provided StorageClass as encrypted.
func MustSyncGVKToObject ¶ added in v1.9.0
MustSyncGVKToObject synchronizes the group, version, and kind for a given object back into the object by looking up the information from the provided scheme.
For more information, please see Update 1 from the following issue: https://github.com/kubernetes-sigs/controller-runtime/issues/2382.
func PatchSnapshotSuccessStatus ¶ added in v1.10.0
func PatchSnapshotSuccessStatus( ctx context.Context, logger logr.Logger, k8sClient ctrlclient.Client, snap *vmopv1.VirtualMachineSnapshot, snapNode *vimtypes.VirtualMachineSnapshotTree, vmPowerState vmopv1.VirtualMachinePowerState) error
PatchSnapshotSuccessStatus patches the snapshot status to reflect the success of the snapshot operation.
func RemoveVMOperatorLabels ¶ added in v1.10.0
RemoveVMOperatorLabels returns a copy of the labels map with all VM Operator managed labels removed. VM Operator managed labels are identified with the "vmoperator.vmware.com" domain in their key.
func SetStoragePolicyID ¶ added in v1.9.0
func SetStoragePolicyID(obj *storagev1.StorageClass, id string)
SetStoragePolicyID sets the storage policy ID on the given StorageClass. An empty id removes the parameter from the StorageClass.
func SyncGVKToObject ¶ added in v1.8.6
SyncGVKToObject synchronizes the group, version, and kind for a given object back into the object by looking up the information from the provided scheme.
For more information, please see Update 1 from the following issue: https://github.com/kubernetes-sigs/controller-runtime/issues/2382.
Types ¶
type EnqueueRequestForObject ¶ added in v1.10.0
type EnqueueRequestForObject = TypedEnqueueRequestForObject[client.Object]
EnqueueRequestForObject enqueues a Request containing the Name and Namespace of the object that is the source of the Event, e.g. the created / deleted / updated objects Name and Namespace).
type ErrMissingParameter ¶ added in v1.9.0
ErrMissingParameter is returned from GetStoragePolicyID if the StorageClass does not have the storage policy ID parameter.
func (ErrMissingParameter) Error ¶ added in v1.9.0
func (e ErrMissingParameter) Error() string
func (ErrMissingParameter) String ¶ added in v1.9.0
func (e ErrMissingParameter) String() string
type GetPriorityFn ¶ added in v1.10.0
type GetPriorityFn[T client.Object] func( ctx context.Context, eventType EventType, newObj, oldObj T, defaultPriority int) int
GetPriorityFn is a function that may be used with a mapper that allows the specification of a custom priority.
type TypedEnqueueRequestForObject ¶ added in v1.10.0
type TypedEnqueueRequestForObject[T client.Object] struct { Logger logr.Logger // GetPriority returns the priority to use when submitting the object to the // queue. GetPriority GetPriorityFn[T] }
TypedEnqueueRequestForObject enqueues a Request containing the Name and Namespace of the object that is the source of the Event, e.g. the created / deleted / updated objects Name and Namespace).
func (*TypedEnqueueRequestForObject[T]) Create ¶ added in v1.10.0
func (e *TypedEnqueueRequestForObject[T]) Create( ctx context.Context, evt event.TypedCreateEvent[T], q workqueue.TypedRateLimitingInterface[reconcile.Request])
Create implements EventHandler.
func (*TypedEnqueueRequestForObject[T]) Delete ¶ added in v1.10.0
func (e *TypedEnqueueRequestForObject[T]) Delete( ctx context.Context, evt event.TypedDeleteEvent[T], q workqueue.TypedRateLimitingInterface[reconcile.Request])
Delete implements EventHandler.
func (*TypedEnqueueRequestForObject[T]) Generic ¶ added in v1.10.0
func (e *TypedEnqueueRequestForObject[T]) Generic( ctx context.Context, evt event.TypedGenericEvent[T], q workqueue.TypedRateLimitingInterface[reconcile.Request])
Generic implements EventHandler.
func (*TypedEnqueueRequestForObject[T]) Update ¶ added in v1.10.0
func (e *TypedEnqueueRequestForObject[T]) Update( ctx context.Context, evt event.TypedUpdateEvent[T], q workqueue.TypedRateLimitingInterface[reconcile.Request])
Update implements EventHandler.
type TypedResourceVersionChangedPredicate ¶ added in v1.9.0
type TypedResourceVersionChangedPredicate[T metav1.Object] struct { predicate.TypedFuncs[T] }
TypedResourceVersionChangedPredicate implements a default update predicate function on resource version change.
func (TypedResourceVersionChangedPredicate[T]) Update ¶ added in v1.9.0
func (TypedResourceVersionChangedPredicate[T]) Update( e event.TypedUpdateEvent[T]) bool
Update implements default UpdateEvent filter for validating resource version change.