Documentation ¶
Overview ¶
Package utils provide utilities like buildinfo
Index ¶
- Constants
- Variables
- func AddGRPCRequestID(ctx context.Context, method string, req, reply interface{}, ...) error
- func CheckBackupSupport(pv corev1.PersistentVolume) error
- func CheckServerUnavailable(err error) bool
- func Contains(s []string, str string) bool
- func ContainsAnnotation(meta metav1.Object, annotation string) bool
- func ContainsFinalizer(meta metav1.Object, finalizer string) bool
- func FileToResource(filePath string) *pb.Resource
- func FindMatchedStrings(kind string, allList []string, includeList, excludeList []kahuapi.ResourceSpec) []string
- func GetAnnotation(meta metav1.Object, annotation string) (string, bool)
- func GetBackupIdentifier(backup *kahuapi.Backup, backupLocation *kahuapi.BackupLocation, ...) (*pb.BackupIdentifier, error)
- func GetBackupLocation(logger log.FieldLogger, locationName string, ...) (*kahuapi.BackupLocation, error)
- func GetBackupParameters(logger log.FieldLogger, backupName, backupLocationName string, ...) (map[string]string, error)
- func GetConfig(kubeConfig string) (config *restclient.Config, err error)
- func GetDynamicClient(config *restclient.Config) (dynamic.Interface, error)
- func GetGRPCConnection(endpoint string, dialOptions ...grpc.DialOption) (*grpc.ClientConn, error)
- func GetK8sClient(config *restclient.Config) (*kubernetes.Clientset, error)
- func GetMetaserviceBackupClient(address string, port uint) metaservice.MetaService_BackupClient
- func GetMetaserviceClient(grpcConnection *grpc.ClientConn) metaservice.MetaServiceClient
- func GetMetaserviceDeleteClient(address string, port uint) metaservice.MetaServiceClient
- func GetProvider(logger log.FieldLogger, providerName string, ...) (*kahuapi.Provider, error)
- func GetResultantItems(allList, includeList, excludeList []string) []string
- func GetSubItemStrings(allList []string, input string, isRegex bool) []string
- func GetgrpcConn(address string, port uint) (*grpc.ClientConn, error)
- func NamespaceAndName(objMeta metav1.Object) string
- func Probe(conn grpc.ClientConnInterface, timeout time.Duration) error
- func RemoveAnnotation(meta metav1.Object, annotation string)
- func RemoveFinalizer(meta metav1.Object, finalizer string)
- func RemoveItem(s []string, r string) []string
- func ResourceToFile(backupHandle string, resource *pb.Resource) string
- func SetAnnotation(meta metav1.Object, annotation, value string)
- func SetFinalizer(meta metav1.Object, finalizer string)
- func SetupSignalHandler(cancel context.CancelFunc)
- func StoreClean(store Store, obj interface{}, className string) error
- func StoreRevisionUpdate(store Store, obj interface{}, className string) (bool, error)
- func ValidateIncludesExcludes(includesList, excludesList []string) []error
- func ValidateNamespace(includesList, excludesList []string) []error
- func VolumeProvider(pv *corev1.PersistentVolume) string
- type BuildInfo
- type KeyFunc
- type Store
- type StoreError
Constants ¶
const ( BackupLocationServiceAnnotation = "kahu.io/provider-service" NamespaceAnnotation = "kahu.io/provider-namespace" InsecureAnnotation = "kahu.io/provider-insecure-grpc-connection" NamespaceEnv = "NAMESPACE" )
const ( Pod = "Pod" Service = "Service" Deployment = "Deployment" Replicaset = "ReplicaSet" StatefulSet = "StatefulSet" DaemonSet = "DaemonSet" Configmap = "ConfigMap" Secret = "Secret" PVC = "PersistentVolumeClaim" PV = "PersistentVolume" Endpoint = "Endpoint" SC = "StorageClass" Backup = "Backup" VBC = "VolumeBackupContent" KahuSnapshot = "VolumeSnapshot" BackupLocation = "BackupLocation" Node = "Node" Event = "Event" VolumeSnapshot = "VolumeSnapshot" ClusterRole = "ClusterRole" ClusterRoleBinding = "ClusterRoleBinding" Role = "Role" RoleBinding = "RoleBinding" ServiceAccount = "ServiceAccount" EndpointSlice = "EndpointSlice" AnnBackupLocationParam = "kahu.io/backup-location-parameter" )
const ( EventOwnerNotDeleted = "OwnerNotDeleted" EventCancelVolRestoreFailed = "CancelVolRestoreFailed" )
Variables ¶
var ( GVKPersistentVolumeClaim = schema.GroupVersionKind{Group: corev1.SchemeGroupVersion.Group, Version: corev1.SchemeGroupVersion.Version, Kind: "PersistentVolumeClaim"} GVKRestore = schema.GroupVersionKind{Group: kahuapi.SchemeGroupVersion.Group, Version: kahuapi.SchemeGroupVersion.Version, Kind: "Restore"} GVKBackup = schema.GroupVersionKind{Group: kahuapi.SchemeGroupVersion.Group, Version: kahuapi.SchemeGroupVersion.Version, Kind: "Backup"} DeletionHandlingMetaNamespaceKeyFunc = cache.DeletionHandlingMetaNamespaceKeyFunc )
var SupportedCsiDrivers = []string{""}
var SupportedResourceList = []string{Pod, Service, Deployment, Replicaset, StatefulSet, DaemonSet, Configmap, Secret, PVC, PV, Endpoint, SC, }
Functions ¶
func AddGRPCRequestID ¶ added in v0.1.1
func AddGRPCRequestID(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error
func CheckBackupSupport ¶ added in v0.1.1
func CheckBackupSupport(pv corev1.PersistentVolume) error
CheckBackupSupport checks if PV is t be considered for backup or not
func CheckServerUnavailable ¶ added in v0.1.1
func ContainsAnnotation ¶ added in v0.1.1
ContainsAnnotation checks for Annotation existence.
func ContainsFinalizer ¶ added in v0.1.1
ContainsFinalizer checks for finalizer existence.
func FileToResource ¶ added in v0.1.1
func FindMatchedStrings ¶ added in v0.1.1
func FindMatchedStrings(kind string, allList []string, includeList, excludeList []kahuapi.ResourceSpec) []string
func GetAnnotation ¶ added in v0.1.1
GetAnnotation checks and return for annotation value.
func GetBackupIdentifier ¶ added in v0.1.1
func GetBackupIdentifier(backup *kahuapi.Backup, backupLocation *kahuapi.BackupLocation, backupProvider *kahuapi.Provider) (*pb.BackupIdentifier, error)
func GetBackupLocation ¶ added in v0.1.1
func GetBackupLocation( logger log.FieldLogger, locationName string, backupLocationLister kahulister.BackupLocationLister) (*kahuapi.BackupLocation, error)
func GetBackupParameters ¶ added in v0.1.1
func GetBackupParameters( logger log.FieldLogger, backupName, backupLocationName string, backupLocationLister kahulister.BackupLocationLister, backupProviderLister kahulister.ProviderLister) (map[string]string, error)
func GetDynamicClient ¶ added in v0.1.1
func GetDynamicClient(config *restclient.Config) (dynamic.Interface, error)
func GetGRPCConnection ¶ added in v0.1.1
func GetGRPCConnection(endpoint string, dialOptions ...grpc.DialOption) (*grpc.ClientConn, error)
func GetK8sClient ¶ added in v0.1.1
func GetK8sClient(config *restclient.Config) (*kubernetes.Clientset, error)
func GetMetaserviceBackupClient ¶ added in v0.1.1
func GetMetaserviceBackupClient(address string, port uint) metaservice.MetaService_BackupClient
func GetMetaserviceClient ¶ added in v0.1.1
func GetMetaserviceClient(grpcConnection *grpc.ClientConn) metaservice.MetaServiceClient
func GetMetaserviceDeleteClient ¶ added in v0.1.1
func GetMetaserviceDeleteClient(address string, port uint) metaservice.MetaServiceClient
func GetProvider ¶ added in v0.1.1
func GetProvider( logger log.FieldLogger, providerName string, providerLister kahulister.ProviderLister) (*kahuapi.Provider, error)
func GetResultantItems ¶ added in v0.1.1
func GetSubItemStrings ¶ added in v0.1.1
func GetgrpcConn ¶ added in v0.1.1
func GetgrpcConn(address string, port uint) (*grpc.ClientConn, error)
func NamespaceAndName ¶
func RemoveAnnotation ¶ added in v0.1.1
RemoveAnnotation removes annotation if it exists.
func RemoveFinalizer ¶ added in v0.1.1
RemoveFinalizer removes a finalizer if it exists.
func RemoveItem ¶ added in v0.1.1
func SetAnnotation ¶ added in v0.1.1
SetAnnotation append Annotation if not exists.
func SetFinalizer ¶ added in v0.1.1
SetFinalizer append finalizer if not exists.
func SetupSignalHandler ¶ added in v0.1.1
func SetupSignalHandler(cancel context.CancelFunc)
func StoreClean ¶ added in v0.1.1
StoreClean delete given cache with the object version from Informer callback (i.e. with events from etcd) or with an object modified by the controller itself. Returns error if face any issue during delete
func StoreRevisionUpdate ¶ added in v0.1.1
StoreRevisionUpdate updates given cache with a new object version from Informer callback (i.e. with events from etcd) or with an object modified by the controller itself. Returns "true", if the cache was updated, false if the object is an old version and should be ignored.
func ValidateNamespace ¶ added in v0.1.1
func VolumeProvider ¶ added in v1.0.0
func VolumeProvider(pv *corev1.PersistentVolume) string
Types ¶
type BuildInfo ¶ added in v0.1.1
type BuildInfo struct { GitVersion string `json:"gitVersion"` GitCommit string `json:"gitCommit"` GitTreeState string `json:"gitTreeState"` BuildDate string `json:"buildDate"` GoVersion string `json:"goVersion"` Compiler string `json:"compiler"` Platform string `json:"platform"` }
BuildInfo contains build information
func GetBuildInfo ¶ added in v0.1.1
func GetBuildInfo() BuildInfo
GetBuildInfo returns the overall code build info
type KeyFunc ¶ added in v0.1.1
KeyFunc knows how to make a key from an object. Implementations should be deterministic.
type Store ¶ added in v0.1.1
type Store interface { // Add adds the given object to the accumulator associated with the given object's key Add(obj interface{}, value interface{}) error // Update updates the given object in the accumulator associated with the given object's key Update(obj interface{}, value interface{}) error // Delete deletes the given object from the accumulator associated with the given object's key Delete(obj interface{}) error // Get returns the accumulator associated with the given object's key Get(obj interface{}) (item interface{}, exists bool, err error) // List returns a list of all the currently non-empty accumulators List() []interface{} // ListKeys returns a list of all the keys currently associated with non-empty accumulators ListKeys() []string }
type StoreError ¶ added in v0.1.1
type StoreError struct { Obj interface{} Err error }
StoreError will be returned any time a Store gives an error; it includes the object at fault.
func (StoreError) Error ¶ added in v0.1.1
func (k StoreError) Error() string
Error gives a human-readable description of the error.