Documentation ¶
Overview ¶
Package utils to provide utils for storageBackend
Package utils to provide utils for storageBackend ¶
Package utils to provide k8s resource utils ¶
Package utils is leader election related utils ¶
Package utils to provide utils for storageBackend
Index ¶
- Constants
- func CombineMap[K comparable, V any](dst map[K]V, src map[K]V) map[K]V
- func ConvertMapString2MapInterface(param map[string]string) map[string]interface{}
- func ConvertToMapValueX[T bool | string | int64 | map[string]interface{}](ctx context.Context, m map[string]interface{}) map[string]T
- func ConvertToStringSlice(inputs []interface{}) []string
- func CreateContent(ctx context.Context, client clientSet.Interface, ...) (*xuanwuv1.StorageBackendContent, error)
- func DeleteContent(ctx context.Context, client clientSet.Interface, contentName string) error
- func Errorf(ctx context.Context, format string, a ...interface{}) error
- func Errorln(ctx context.Context, msg string) error
- func GenDynamicContentName(storageBackend *xuanwuv1.StorageBackendClaim) string
- func GenObjectMetaKey(obj interface{}) (string, error)
- func GetBackendConfigmapByClaimName(ctx context.Context, claimNameMeta string) (*coreV1.ConfigMap, error)
- func GetBackendSecret(ctx context.Context, secretMeta string) (*coreV1.Secret, error)
- func GetCertMeta(ctx context.Context, claimNameMeta string) (bool, string, error)
- func GetCertPool(ctx context.Context, useCert bool, secretMeta string) (bool, *x509.CertPool, error)
- func GetCertSecretFromBackendID(ctx context.Context, backendID string) (bool, string, error)
- func GetClaim(ctx context.Context, client clientSet.Interface, ...) (*xuanwuv1.StorageBackendClaim, error)
- func GetClaimByMeta(ctx context.Context, claimNameMeta string) (*xuanwuv1.StorageBackendClaim, error)
- func GetConfigMap(configmapMeta string) (*coreV1.ConfigMap, error)
- func GetConfigMeta(ctx context.Context, claimNameMeta string) (string, string, error)
- func GetContent(ctx context.Context, client clientSet.Interface, contentName string) (*xuanwuv1.StorageBackendContent, error)
- func GetContentByClaimMeta(ctx context.Context, claimNameMeta string) (*xuanwuv1.StorageBackendContent, error)
- func GetK8SAndCrdClient(ctx context.Context) (*kubernetes.Clientset, *clientSet.Clientset, error)
- func GetNameSpaceFromEnv(namespaceEnv, defaultNamespace string) string
- func GetPasswordFromBackendID(ctx context.Context, backendID string) (string, error)
- func GetSBCTCapabilitiesByClaim(ctx context.Context, backendID string) (map[string]bool, error)
- func GetSBCTOnlineStatusByClaim(ctx context.Context, backendID string) (bool, error)
- func GetSBCTOnlineStatusByContent(ctx context.Context, content *xuanwuv1.StorageBackendContent) (bool, error)
- func GetSecret(meta string) (*coreV1.Secret, error)
- func InitRecorder(client kubernetes.Interface, componentName string) record.EventRecorder
- func IsBackendCapabilitySupport(ctx context.Context, backendID string, capability constants.BackendCapability) (bool, error)
- func IsClaimBoundContent(storageBackend *xuanwuv1.StorageBackendClaim) bool
- func IsClaimReady(storageBackend *xuanwuv1.StorageBackendClaim) bool
- func IsContentReady(ctx context.Context, content *xuanwuv1.StorageBackendContent) bool
- func IsSBCTExist(ctx context.Context, backendID string) bool
- func IsSBCTOnline(ctx context.Context, backendID string) bool
- func ListClaim(ctx context.Context, client clientSet.Interface, namespace string) (*xuanwuv1.StorageBackendClaimList, error)
- func ListContent(ctx context.Context, client clientSet.Interface) (*xuanwuv1.StorageBackendContentList, error)
- func MakeMetaWithNamespace(ns, name string) string
- func NeedAddClaimBoundFinalizers(storageBackend *xuanwuv1.StorageBackendClaim) bool
- func NeedAddContentBoundFinalizers(content *xuanwuv1.StorageBackendContent) bool
- func NeedChangeContent(storageBackend *xuanwuv1.StorageBackendClaim) bool
- func NeedRemoveClaimBoundFinalizers(storageBackend *xuanwuv1.StorageBackendClaim) bool
- func NeedRemoveContentBoundFinalizers(content *xuanwuv1.StorageBackendContent) bool
- func Publish(ctx context.Context, key string, args ...interface{})
- func RunWithLeaderElection(ctx context.Context, leaderElection LeaderElectionConf, ...)
- func SetSBCTOnlineStatus(ctx context.Context, content *xuanwuv1.StorageBackendContent, status bool) error
- func SetStorageBackendContentOnlineStatus(ctx context.Context, backendID string, online bool) error
- func SplitMetaNamespaceKey(obj string) (namespace, name string, err error)
- func StorageBackendClaimKey(storageBackend *xuanwuv1.StorageBackendClaim) string
- func StoreObjectUpdate(ctx context.Context, store cache.Store, obj interface{}, className string) (bool, error)
- func Subscribe(topic string, fn interface{})
- func UpdateClaim(ctx context.Context, client clientSet.Interface, ...) (*xuanwuv1.StorageBackendClaim, error)
- func UpdateClaimStatus(ctx context.Context, client clientSet.Interface, ...) (*xuanwuv1.StorageBackendClaim, error)
- func UpdateConfigMap(configmap *coreV1.ConfigMap) (*coreV1.ConfigMap, error)
- func UpdateContent(ctx context.Context, client clientSet.Interface, ...) (*xuanwuv1.StorageBackendContent, error)
- func UpdateContentStatus(ctx context.Context, client clientSet.Interface, ...) (*xuanwuv1.StorageBackendContent, error)
- func WaitExitSignal(ctx context.Context, components string)
- type LeaderElectionConf
Constants ¶
const ( // ConfigMapFinalizer used when configmap as a resource to create StorageBackendContent ConfigMapFinalizer = "storagebackend.xuanwu.huawei.io/configmap-protection" // SecretFinalizer used when secret as a resource to create StorageBackendContent SecretFinalizer = "storagebackend.xuanwu.huawei.io/secret-protection" // ClaimBoundFinalizer used when storageBackendClaim bound to a storageBackendContent ClaimBoundFinalizer = "storagebackend.xuanwu.huawei.io/storagebackendclaim-bound-protection" // ContentBoundFinalizer used when storageBackendContent bound to a storageBackendClaim ContentBoundFinalizer = "storagebackend.xuanwu.huawei.io/storagebackendcontent-bound-protection" )
const (
// BackendStatus backend status topic
BackendStatus = "BACKEND_STATUS"
)
Variables ¶
This section is empty.
Functions ¶
func CombineMap ¶
func CombineMap[K comparable, V any](dst map[K]V, src map[K]V) map[K]V
CombineMap combines two maps and returns a new map, if there's a key conflict, subject to the destination map.
func ConvertMapString2MapInterface ¶
ConvertMapString2MapInterface used to convert map[string]string to map[string]interface
func ConvertToMapValueX ¶
func ConvertToMapValueX[T bool | string | int64 | map[string]interface{}](ctx context.Context, m map[string]interface{}) map[string]T
ConvertToMapValueX convert map value to x
func ConvertToStringSlice ¶
func ConvertToStringSlice(inputs []interface{}) []string
ConvertToStringSlice convert interface slice to string slice
func CreateContent ¶
func CreateContent(ctx context.Context, client clientSet.Interface, content *xuanwuv1.StorageBackendContent) ( *xuanwuv1.StorageBackendContent, error)
CreateContent used to create content by xuanwu client
func DeleteContent ¶
DeleteContent used to delete content by xuanwu client
func GenDynamicContentName ¶
func GenDynamicContentName(storageBackend *xuanwuv1.StorageBackendClaim) string
GenDynamicContentName return the uniq name of StorageBackendContent
func GenObjectMetaKey ¶
GenObjectMetaKey return the meta namespace key
func GetBackendSecret ¶
func GetCertMeta ¶
GetCertMeta get cert meta from backend claim
func GetCertPool ¶
func GetCertPool(ctx context.Context, useCert bool, secretMeta string) (bool, *x509.CertPool, error)
GetCertPool get cert pool
func GetCertSecretFromBackendID ¶
GetCertSecretFromBackendID get cert secret meta from backend
func GetClaim ¶
func GetClaim(ctx context.Context, client clientSet.Interface, storageBackend *xuanwuv1.StorageBackendClaim) ( *xuanwuv1.StorageBackendClaim, error)
GetClaim used to get claim by xuanwu client
func GetClaimByMeta ¶
func GetConfigMap ¶
GetConfigMap is to get configmap using storage backend claim
func GetConfigMeta ¶
func GetContent ¶
func GetContent(ctx context.Context, client clientSet.Interface, contentName string) ( *xuanwuv1.StorageBackendContent, error)
GetContent used to get content by xuanwu client
func GetContentByClaimMeta ¶
func GetK8SAndCrdClient ¶
GetK8SAndCrdClient return k8sClient, crdClient
func GetNameSpaceFromEnv ¶
GetNameSpaceFromEnv get the namespace from the env
func GetSBCTCapabilitiesByClaim ¶
GetSBCTCapabilitiesByClaim get backend capabilities
func GetSBCTOnlineStatusByContent ¶
func GetSBCTOnlineStatusByContent(ctx context.Context, content *xuanwuv1.StorageBackendContent) (bool, error)
GetSBCTOnlineStatusByContent get backend capabilities by SBCT
func InitRecorder ¶
func InitRecorder(client kubernetes.Interface, componentName string) record.EventRecorder
InitRecorder used to init event recorder
func IsBackendCapabilitySupport ¶
func IsBackendCapabilitySupport(ctx context.Context, backendID string, capability constants.BackendCapability) (bool, error)
IsBackendCapabilitySupport valid backend capability
func IsClaimBoundContent ¶
func IsClaimBoundContent(storageBackend *xuanwuv1.StorageBackendClaim) bool
IsClaimBoundContent indicates whether StorageBackendClaim bound to StorageBackendContent
func IsClaimReady ¶
func IsClaimReady(storageBackend *xuanwuv1.StorageBackendClaim) bool
IsClaimReady returns StorageBackendClaim ready or not
func IsContentReady ¶
func IsContentReady(ctx context.Context, content *xuanwuv1.StorageBackendContent) bool
IsContentReady returns StorageBackendContent ready or not
func ListClaim ¶
func ListClaim(ctx context.Context, client clientSet.Interface, namespace string) (*xuanwuv1.StorageBackendClaimList, error)
ListClaim used to list claims by xuanwu client
func ListContent ¶
func ListContent(ctx context.Context, client clientSet.Interface) (*xuanwuv1.StorageBackendContentList, error)
ListContent used to list contents by xuanwu client
func MakeMetaWithNamespace ¶
MakeMetaWithNamespace used to make a backendID
func NeedAddClaimBoundFinalizers ¶
func NeedAddClaimBoundFinalizers(storageBackend *xuanwuv1.StorageBackendClaim) bool
NeedAddClaimBoundFinalizers returns whether to add a Finalizer to claim
func NeedAddContentBoundFinalizers ¶
func NeedAddContentBoundFinalizers(content *xuanwuv1.StorageBackendContent) bool
NeedAddContentBoundFinalizers returns whether to add a Finalizer to content
func NeedChangeContent ¶
func NeedChangeContent(storageBackend *xuanwuv1.StorageBackendClaim) bool
NeedChangeContent returns need update content or not
func NeedRemoveClaimBoundFinalizers ¶
func NeedRemoveClaimBoundFinalizers(storageBackend *xuanwuv1.StorageBackendClaim) bool
NeedRemoveClaimBoundFinalizers returns whether to add a Finalizer
func NeedRemoveContentBoundFinalizers ¶
func NeedRemoveContentBoundFinalizers(content *xuanwuv1.StorageBackendContent) bool
NeedRemoveContentBoundFinalizers returns whether to add a Finalizer
func RunWithLeaderElection ¶
func RunWithLeaderElection(ctx context.Context, leaderElection LeaderElectionConf, k8sClient *kubernetes.Clientset, recorder record.EventRecorder, runFunc func(ctx context.Context, ch chan os.Signal), ch chan os.Signal)
RunWithLeaderElection run with leader election
func SetSBCTOnlineStatus ¶
func SplitMetaNamespaceKey ¶
SplitMetaNamespaceKey returns the namespace and name
func StorageBackendClaimKey ¶
func StorageBackendClaimKey(storageBackend *xuanwuv1.StorageBackendClaim) string
StorageBackendClaimKey return the uniq name of claim
func StoreObjectUpdate ¶
func StoreObjectUpdate(ctx context.Context, store cache.Store, obj interface{}, className string) (bool, error)
StoreObjectUpdate updates given cache with a new object version from Informer
func UpdateClaim ¶
func UpdateClaim(ctx context.Context, client clientSet.Interface, storageBackend *xuanwuv1.StorageBackendClaim) ( *xuanwuv1.StorageBackendClaim, error)
UpdateClaim used to update claim by xuanwu client
func UpdateClaimStatus ¶
func UpdateClaimStatus(ctx context.Context, client clientSet.Interface, storageBackend *xuanwuv1.StorageBackendClaim) ( *xuanwuv1.StorageBackendClaim, error)
UpdateClaimStatus used to update claim status by xuanwu client
func UpdateConfigMap ¶
UpdateConfigMap is to update configmap using storage backend claim
func UpdateContent ¶
func UpdateContent(ctx context.Context, client clientSet.Interface, content *xuanwuv1.StorageBackendContent) ( *xuanwuv1.StorageBackendContent, error)
UpdateContent used to update content by xuanwu client
func UpdateContentStatus ¶
func UpdateContentStatus(ctx context.Context, client clientSet.Interface, content *xuanwuv1.StorageBackendContent) ( *xuanwuv1.StorageBackendContent, error)
UpdateContentStatus used to update content status by xuanwu client
func WaitExitSignal ¶
WaitExitSignal is used to wait exits signal, components e.g. webhook, controller