Documentation
¶
Index ¶
- Constants
- Variables
- 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 HasCAPILabels(vmLabels 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 SetStoragePolicyID(obj *storagev1.StorageClass, id string)
- func SyncGVKToObject(obj runtime.Object, scheme *runtime.Scheme) error
- func VMForControllerPredicate(c client.Client, log logr.Logger, controllerName string, ...) predicate.Predicate
- type ErrMissingParameter
- type TypedResourceVersionChangedPredicate
- type VMForControllerPredicateOptions
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" )
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 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 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 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 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.
func VMForControllerPredicate ¶
func VMForControllerPredicate( c client.Client, log logr.Logger, controllerName string, opts VMForControllerPredicateOptions) predicate.Predicate
VMForControllerPredicate returns a predicate.Predicate that filters VirtualMachine resources and returns only those that map to a VirtualMachineClass resource that uses the provided controller.
Please note this predicate is schema agnostic and should work with all VM Operator API schema versions.
Types ¶
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 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.
type VMForControllerPredicateOptions ¶
type VMForControllerPredicateOptions struct {
MatchIfVMClassNotFound bool
MatchIfControllerNameFieldEmpty bool
MatchIfControllerNameFieldMissing bool
}
VMForControllerPredicateOptions is used to configure the behavior of the predicate created with VMForControllerPredicate.