Documentation
¶
Index ¶
- Constants
- Variables
- func CalculateMD5Hash(value any) string
- func CalculateStorageId(ctx context.Context, c client.Client, sc storagev1.StorageClass, ...) (string, error)
- func CompareSemverMajorMinorVersions(v1, v2 string, opr operator) (bool, error)
- func ContainsPeerRef(slice []multiclusterv1alpha1.PeerRef, peerRef *multiclusterv1alpha1.PeerRef) bool
- func ContainsString(slice []string, s string) bool
- func ContainsSubject(slice []rbacv1.Subject, subject *rbacv1.Subject) bool
- func ContainsSuffix(slice []string, s string) bool
- func CreateOrUpdateManagedClusterView(ctx context.Context, client ctrlClient.Client, resourceToFindName string, ...) (*viewv1beta1.ManagedClusterView, controllerutil.OperationResult, error)
- func CreateOrUpdateManifestWork(ctx context.Context, c client.Client, name string, namespace string, ...) (controllerutil.OperationResult, error)
- func CreateOrUpdateObjectBucketClaim(ctx context.Context, c client.Client, bucketName, bucketNamespace string, ...) (controllerutil.OperationResult, error)
- func CreateOrUpdateSecretsFromInternalSecret(ctx context.Context, rc client.Client, scheme *runtime.Scheme, ...) error
- func CreateUniqueName(params ...string) string
- func CreateUniqueSecretName(managedCluster, storageClusterNamespace, storageClusterName string, ...) string
- func CreateUniqueSecretNameForClient(providerKey, clientKey1, clientKey2 string) string
- func DecodeConfigMap(objJson []byte) (*corev1.ConfigMap, error)
- func DoesAnotherMirrorPeerPointToPeerRef(ctx context.Context, rc client.Client, peerRef *multiclusterv1alpha1.PeerRef) (bool, error)
- func EventTypePredicate(create, update, del, generic bool) predicate.Predicate
- func FetchAllMirrorPeers(ctx context.Context, rc client.Client) ([]multiclusterv1alpha1.MirrorPeer, error)
- func FetchAllSecretsWithLabel(ctx context.Context, rc client.Client, namespace string, ...) ([]corev1.Secret, error)
- func FetchCephCluster(ctx context.Context, c client.Client, ...) (*rookv1.CephCluster, error)
- func FetchClientInfoConfigMap(ctx context.Context, c client.Client, currentNamespace string) (*corev1.ConfigMap, error)
- func FetchConfigMap(ctx context.Context, c client.Client, name, namespace string) (*corev1.ConfigMap, error)
- func FetchMirrorPeerByName(ctx context.Context, rc client.Client, name string) (*multiclusterv1alpha1.MirrorPeer, error)
- func FetchSecretWithName(ctx context.Context, rc client.Client, secretName types.NamespacedName) (*corev1.Secret, error)
- func FnvHash(s string) uint32
- func GenerateBucketName(mirrorPeer multiclusterv1alpha1.MirrorPeer) string
- func GenerateUniqueIdForMirrorPeer(mirrorPeer multiclusterv1alpha1.MirrorPeer) string
- func GetClientConfig(kubeConfigFile string) (*rest.Config, error)
- func GetClientFromConfig(config *rest.Config, scheme *runtime.Scheme) (client.Client, error)
- func GetClusterID(ctx context.Context, client client.Client, clusterName string) (string, error)
- func GetCurrentStorageClusterRef(mp *multiclusterv1alpha1.MirrorPeer, spokeClusterName string) (*multiclusterv1alpha1.StorageClusterRef, error)
- func GetDefaultStorageClasses(ctx context.Context, c client.Client, storageClusterName string) ([]storagev1.StorageClass, error)
- func GetDefaultVolumeSnapshotClasses(ctx context.Context, c client.Client, storageClusterName string) ([]*snapshotv1.VolumeSnapshotClass, error)
- func GetEnv(key string, filenames ...string) string
- func GetEnvOrDefault(key, defaultValue string, filenames ...string) string
- func GetKey(clusterName, clientName string) string
- func GetLogger(zapL *zap.Logger) *slog.Logger
- func GetManagedClusterById(ctx context.Context, c client.Client, clusterId string) (*clusterv1.ManagedCluster, error)
- func GetManagedClusterViewName(clusterName string) string
- func GetManifestWork(ctx context.Context, c client.Client, manifestWorkName string, ...) (*workv1.ManifestWork, error)
- func GetMirrorPeerForClusterSet(ctx context.Context, client client.Client, clusterSet []string) (*multiclusterv1alpha1.MirrorPeer, error)
- func GetNamespacedNameForClusterInfo(managedCluster clusterv1.ManagedCluster) (types.NamespacedName, error)
- func GetODFInfoConfigMap(ctx context.Context, c client.Client, namespace string) (*corev1.ConfigMap, error)
- func GetObjectBucketClaim(ctx context.Context, c client.Client, bucketName, bucketNamespace string) (*obv1alpha1.ObjectBucketClaim, error)
- func GetPeerRefForProviderCluster(ctx context.Context, spokeClient, hubClient client.Client, ...) ([]multiclusterv1alpha1.PeerRef, error)
- func GetPeerRefForSpokeCluster(mp *multiclusterv1alpha1.MirrorPeer, spokeClusterName string) (*multiclusterv1alpha1.PeerRef, error)
- func GetSecretNameByPeerRef(pr multiclusterv1alpha1.PeerRef, prefix ...string) string
- func GetStorageClientMapping(ctx context.Context, c client.Client, currentNamespace string) (*corev1.ConfigMap, error)
- func GetStorageClusterFromCurrentNamespace(ctx context.Context, c client.Client, namespace string) (*ocsv1.StorageCluster, error)
- func GetStorageIdsForDefaultStorageClasses(ctx context.Context, c client.Client, scNamespacedName types.NamespacedName, ...) (map[CephType]string, error)
- func GetVolumeSnapshotClass(ctx context.Context, c client.Client, volumeSnapshotClassName string) (*snapshotv1.VolumeSnapshotClass, error)
- func GetZapLogger(dev bool) *zap.Logger
- func HasHubRecoveryLabels(secret *corev1.Secret) bool
- func HasRequiredODFKey(mc *clusterv1.ManagedCluster) bool
- func IsSecretInternal(obj client.Object) bool
- func IsStorageClientType(ctx context.Context, c client.Client, ...) (bool, error)
- func ListStorageClasses(ctx context.Context, c client.Client) ([]storagev1.StorageClass, error)
- func NamePredicate(name string) predicate.Predicate
- func NamespacePredicate(namespace string) predicate.Predicate
- func RemoveMirrorPeer(slice []multiclusterv1alpha1.MirrorPeer, ...) (result []multiclusterv1alpha1.MirrorPeer)
- func RemoveString(slice []string, s string) (result []string)
- func ValidateInternalSecret(internalSecret *corev1.Secret, expectedLabel SecretLabelType) error
- func ValidateS3Secret(data map[string][]byte) bool
- type CephType
- type ClientInfo
- type ClusterType
- type InfoCephBlockPool
- type PeerRefType
- type ProviderInfo
- type S3Token
- type SecretLabelType
Constants ¶
const ( ODFInfoConfigMapName = "odf-info" ConfigMapResourceType = "ConfigMap" ClientInfoConfigMapName = "odf-client-info" StorageClientMappingConfigMapName = "storage-client-mapping" StorageClusterPeerNameAnnotationKey = "ocs.openshift.io/storage-cluster-peer" )
const ( BucketGenerateName = "odrbucket" // s3 S3ProfilePrefix = "s3profile" S3Endpoint = "s3CompatibleEndpoint" S3BucketName = "s3Bucket" S3ProfileName = "s3ProfileName" S3Region = "s3Region" AwsAccessKeyId = "AWS_ACCESS_KEY_ID" AwsSecretAccessKey = "AWS_SECRET_ACCESS_KEY" // ramen RamenHubOperatorConfigName = "ramen-hub-operator-config" // handlers RookSecretHandlerName = "rook" S3SecretHandlerName = "s3" DRModeAnnotationKey = "multicluster.openshift.io/mode" MirrorPeerNameAnnotationKey = "multicluster.odf.openshift.io/mirrorpeer" HubOperatorNamespaceKey = "hub.multicluster.odf.openshift.io/operator-namespace" )
const ( InternalLabel SecretLabelType = "INTERNAL" IgnoreLabel SecretLabelType = "IGNORE" ProviderLabel SecretLabelType = "PROVIDER" SecretLabelTypeKey = "multicluster.odf.openshift.io/secret-type" CreatedByLabelKey = "multicluster.odf.openshift.io/created-by" ObjectKindLabelKey = "multicluster.odf.openshift.io/object-kind" CreatorMulticlusterOrchestrator = "odf-multicluster-orchestrator" NamespaceKey = "namespace" StorageClusterNameKey = "storage-cluster-name" SecretDataKey = "secret-data" SecretOriginKey = "secret-origin" MirrorPeerSecret = "mirrorpeersecret" HubRecoveryLabel = "cluster.open-cluster-management.io/backup" )
const ( RBDType CephType = "rbd" CephFSType CephType = "cephfs" RBDProvisionerTemplate = "%s.rbd.csi.ceph.com" CephFSProvisionerTemplate = "%s.cephfs.csi.ceph.com" DefaultVirtualizationStorageClassName = "%s-ceph-rbd-virtualization" DefaultCephRBDStorageClassTemplate = "%s-ceph-rbd" DefaultRadosNamespaceStorageClassTemplate = "%s-ceph-rbd-rados-namespace-" DefaultCephFSStorageClassTemplate = "%s-cephfs" DefaultSubvolumeGroup = "csi" DefaultRadosNamespace = "" )
const ( DefaultCephFSVSCNameTemplate = "%s-cephfsplugin-snapclass" DefaultRBDVSCNameTemplate = "%s-rbdplugin-snapclass" DefaultCephFSVSCDriverTemplate = "%s.cephfs.csi.ceph.com" DefaultRBDVSCDriverTemplate = "%s.rbd.csi.ceph.com" )
const MCVLabelKey = "multicluster.odf.openshift.io/cluster"
const MCVNameTemplate = "odf-multicluster-mcv-%s"
const (
OdfInfoClusterClaimNamespacedName = "odfinfo.odf.openshift.io"
)
Variables ¶
var ( Eq operator = "eq" Lt operator = "lt" Gt operator = "gt" )
var InternalSecretPredicate = predicate.Funcs{ CreateFunc: func(e event.CreateEvent) bool { return IsSecretInternal(e.Object) }, DeleteFunc: func(e event.DeleteEvent) bool { return IsSecretInternal(e.Object) }, UpdateFunc: func(e event.UpdateEvent) bool { return (IsSecretInternal(e.ObjectOld) && IsSecretInternal(e.ObjectNew)) }, GenericFunc: func(_ event.GenericEvent) bool { return false }, }
var OriginMap = map[string]string{"RookOrigin": "rook", "S3Origin": "S3"}
Functions ¶
func CalculateMD5Hash ¶
func CalculateStorageId ¶
func CalculateStorageId(ctx context.Context, c client.Client, sc storagev1.StorageClass, storageClusterNamespacedName types.NamespacedName) (string, error)
func ContainsPeerRef ¶
func ContainsPeerRef(slice []multiclusterv1alpha1.PeerRef, peerRef *multiclusterv1alpha1.PeerRef) bool
ContainsPeerRef checks if a slice of PeerRef contains the provided PeerRef
func ContainsString ¶
ContainsString checks if a slice of strings contains the provided string
func ContainsSuffix ¶
func CreateOrUpdateManagedClusterView ¶
func CreateOrUpdateManagedClusterView(ctx context.Context, client ctrlClient.Client, resourceToFindName string, resourceToFindNamespace string, resourceToFindType string, clusterName string, ownerRef *metav1.OwnerReference) (*viewv1beta1.ManagedClusterView, controllerutil.OperationResult, error)
func CreateOrUpdateManifestWork ¶
func CreateOrUpdateManifestWork(ctx context.Context, c client.Client, name string, namespace string, objJson []byte, manifestConfigOptions []workv1.ManifestConfigOption, ownerRef metav1.OwnerReference) (controllerutil.OperationResult, error)
func CreateOrUpdateObjectBucketClaim ¶
func CreateOrUpdateObjectBucketClaim(ctx context.Context, c client.Client, bucketName, bucketNamespace string, annotations map[string]string) (controllerutil.OperationResult, error)
func CreateUniqueName ¶
CreateUniqueName function creates a sha512 hex sum from the given parameters
func CreateUniqueSecretName ¶
func CreateUniqueSecretName(managedCluster, storageClusterNamespace, storageClusterName string, prefix ...string) string
CreateUniqueSecretName function creates a name of 40 chars using sha512 hex sum from the given parameters
func DoesAnotherMirrorPeerPointToPeerRef ¶
func DoesAnotherMirrorPeerPointToPeerRef(ctx context.Context, rc client.Client, peerRef *multiclusterv1alpha1.PeerRef) (bool, error)
DoesAnotherMirrorPeerPointToPeerRef checks if another mirrorpeer is pointing to the provided peer ref
func EventTypePredicate ¶
EventTypePredicate return a predicate to filter events based on their respective event type. This helper allows for the selection of multiple types resulting in a predicate that can filter in more than a single event type
func FetchAllMirrorPeers ¶
func FetchAllMirrorPeers(ctx context.Context, rc client.Client) ([]multiclusterv1alpha1.MirrorPeer, error)
func FetchAllSecretsWithLabel ¶
func FetchAllSecretsWithLabel(ctx context.Context, rc client.Client, namespace string, secretLabelType SecretLabelType) ([]corev1.Secret, error)
FetchAllSecretsWithLabel will get all the internal secrets in the namespace and with the provided label if the namespace is empty, it will fetch from all the namespaces if the label type is 'Ignore', it will fetch all the internal secrets (both source and destination)
func FetchCephCluster ¶
func FetchCephCluster(ctx context.Context, c client.Client, storageClusterNamespacedName types.NamespacedName) (*rookv1.CephCluster, error)
func FetchConfigMap ¶
func FetchConfigMap(ctx context.Context, c client.Client, name, namespace string) (*corev1.ConfigMap, error)
FetchConfigMap fetches a ConfigMap with a given name from a given namespace
func FetchMirrorPeerByName ¶
func FetchMirrorPeerByName(ctx context.Context, rc client.Client, name string) (*multiclusterv1alpha1.MirrorPeer, error)
func FetchSecretWithName ¶
func FnvHash ¶
fnv64a is a 64-bit non-cryptographic hash algorithm with a low collision and a high distribution rate. https://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
func GenerateBucketName ¶
func GenerateBucketName(mirrorPeer multiclusterv1alpha1.MirrorPeer) string
func GenerateUniqueIdForMirrorPeer ¶
func GenerateUniqueIdForMirrorPeer(mirrorPeer multiclusterv1alpha1.MirrorPeer) string
func GetClientConfig ¶
GetClientConfig returns the rest.Config for a kubeconfig file
func GetClientFromConfig ¶
GetClientFromConfig returns a controller-runtime Client for a rest.Config
func GetClusterID ¶
getClusterID returns the cluster ID of the OCP-Cluster
func GetCurrentStorageClusterRef ¶
func GetCurrentStorageClusterRef(mp *multiclusterv1alpha1.MirrorPeer, spokeClusterName string) (*multiclusterv1alpha1.StorageClusterRef, error)
func GetDefaultVolumeSnapshotClasses ¶
func GetDefaultVolumeSnapshotClasses(ctx context.Context, c client.Client, storageClusterName string) ([]*snapshotv1.VolumeSnapshotClass, error)
func GetEnvOrDefault ¶
func GetManagedClusterById ¶
func GetManagedClusterById(ctx context.Context, c client.Client, clusterId string) (*clusterv1.ManagedCluster, error)
GetManagedClusterById fetches a ManagedCluster by its cluster ID label
func GetManifestWork ¶
func GetMirrorPeerForClusterSet ¶
func GetMirrorPeerForClusterSet(ctx context.Context, client client.Client, clusterSet []string) (*multiclusterv1alpha1.MirrorPeer, error)
func GetNamespacedNameForClusterInfo ¶
func GetNamespacedNameForClusterInfo(managedCluster clusterv1.ManagedCluster) (types.NamespacedName, error)
func GetODFInfoConfigMap ¶
func GetODFInfoConfigMap(ctx context.Context, c client.Client, namespace string) (*corev1.ConfigMap, error)
GetODFInfoConfigMap fetches the odf-info ConfigMap from the given namespace. This will only work on the managed cluster
func GetObjectBucketClaim ¶
func GetObjectBucketClaim(ctx context.Context, c client.Client, bucketName, bucketNamespace string) (*obv1alpha1.ObjectBucketClaim, error)
func GetPeerRefForProviderCluster ¶
func GetPeerRefForProviderCluster(ctx context.Context, spokeClient, hubClient client.Client, mp *multiclusterv1alpha1.MirrorPeer) ([]multiclusterv1alpha1.PeerRef, error)
GetPeerRefForProviderCluster returns the client peer ref for the current provider cluster
func GetPeerRefForSpokeCluster ¶
func GetPeerRefForSpokeCluster(mp *multiclusterv1alpha1.MirrorPeer, spokeClusterName string) (*multiclusterv1alpha1.PeerRef, error)
GetPeerRefForSpokeCluster returns the peer ref for the cluster name
func GetSecretNameByPeerRef ¶
func GetSecretNameByPeerRef(pr multiclusterv1alpha1.PeerRef, prefix ...string) string
func GetStorageClientMapping ¶
func GetVolumeSnapshotClass ¶
func GetVolumeSnapshotClass(ctx context.Context, c client.Client, volumeSnapshotClassName string) (*snapshotv1.VolumeSnapshotClass, error)
func GetZapLogger ¶
func HasHubRecoveryLabels ¶
func HasRequiredODFKey ¶
func HasRequiredODFKey(mc *clusterv1.ManagedCluster) bool
func IsSecretInternal ¶
IsSecretInternal returns true if the provided object is a secret with Inernal label
func IsStorageClientType ¶
func IsStorageClientType(ctx context.Context, c client.Client, mirrorPeer multiclusterv1alpha1.MirrorPeer, operatorNs string) (bool, error)
IsStorageClientType checks if peerRefs on MirrorPeer is of type StorageClient or StorageCluster
func ListStorageClasses ¶
func NamePredicate ¶
Name Predicate return a predicate the filter events produced by resources that matches the given name
func NamespacePredicate ¶
Namespace Predicate return a predicate the filter events produced by resources that matches the given namespace
func RemoveMirrorPeer ¶
func RemoveMirrorPeer(slice []multiclusterv1alpha1.MirrorPeer, mirrorPeer multiclusterv1alpha1.MirrorPeer) (result []multiclusterv1alpha1.MirrorPeer)
RemoveMirrorPeer removes the given mirrorPeer from the slice and returns the new slice
func RemoveString ¶
RemoveString removes a given string from a slice and returns the new slice
func ValidateInternalSecret ¶
func ValidateInternalSecret(internalSecret *corev1.Secret, expectedLabel SecretLabelType) error
func ValidateS3Secret ¶
Types ¶
type CephType ¶
type CephType string
func GetStorageClassType ¶
func GetStorageClassType(sc storagev1.StorageClass, storageClusterNamespace string) (CephType, error)
func GetVolumeSnapshotClassType ¶
func GetVolumeSnapshotClassType(vsc *snapshotv1.VolumeSnapshotClass, storageClusterNamespace string) (CephType, error)
type ClientInfo ¶
type ClientInfo struct { ClusterID string `json:"clusterId"` Name string `json:"name"` ProviderInfo ProviderInfo `json:"providerInfo,omitempty"` ClientManagedClusterName string `json:"clientManagedClusterName,omitempty"` ClientID string `json:"clientId"` }
func GetClientInfoFromConfigMap ¶
func GetClientInfoFromConfigMap(clientInfoMap map[string]string, key string) (ClientInfo, error)
Helper function to extract and unmarshal ClientInfo from ConfigMap
type ClusterType ¶
type ClusterType string
const ( CONVERGED ClusterType = "Converged" EXTERNAL ClusterType = "External" UNKNOWN ClusterType = "Unknown" CephClusterReplicationIdLabel = "replicationid.multicluster.openshift.io" CephClusterNameTemplate = "%s-cephcluster" )
type InfoCephBlockPool ¶
type PeerRefType ¶
type PeerRefType string
const ( // PeerRefTypeStorageClient represents a storage client PeerRefTypeStorageClient PeerRefType = "StorageClient" // PeerRefTypeStorageCluster represents a storage cluster PeerRefTypeStorageCluster PeerRefType = "StorageCluster" // PeerRefTypeUnknown represents an unknown type PeerRefTypeUnknown PeerRefType = "Unknown" )
type ProviderInfo ¶
type ProviderInfo struct { Version string `json:"version"` DeploymentType string `json:"deploymentType"` ProviderManagedClusterName string `json:"providerManagedClusterName"` NamespacedName types.NamespacedName `json:"namespacedName"` StorageProviderEndpoint string `json:"storageProviderEndpoint"` CephClusterFSID string `json:"cephClusterFSID"` StorageProviderPublicEndpoint string `json:"storageProviderPublicEndpoint"` InfoCephBlockPools []InfoCephBlockPool `json:"infoCephBlockPools"` }
type S3Token ¶
type SecretLabelType ¶
type SecretLabelType string
func GetInternalLabel ¶
func GetInternalLabel(secret *corev1.Secret) SecretLabelType