utils

package
v0.3.7-rc.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2022 License: Apache-2.0 Imports: 23 Imported by: 10

Documentation

Index

Constants

View Source
const (
	TimeFormatOnResourceName = "20060102-15"
)

Variables

View Source
var (
	ErrNotLVMByteNum = errors.New("LVM byte format unrecognised")
)
View Source
var (
	// NoOpEventHandlerFuncs for informer
	NoOpEventHandlerFuncs = cache.ResourceEventHandlerFuncs{
		AddFunc:    func(obj interface{}) {},
		UpdateFunc: func(oldObj, newObj interface{}) {},
		DeleteFunc: func(obj interface{}) {},
	}
)

Functions

func AddUniqueStringItem

func AddUniqueStringItem(items []string, itemToAdd string) []string

AddUniqueStringItem add a string from a slice without duplicate

func Bash added in v0.4.0

func Bash(cmd string) (string, error)

func BuildInClusterClientset

func BuildInClusterClientset() (*kubernetes.Clientset, error)

BuildInClusterClientset builds a kubernetes in-cluster clientset

func BuildStoragePoolName

func BuildStoragePoolName(poolClass string, poolType string) (string, error)

BuildStoragePoolName constructs storage pool name

func ConvertBytesToStr

func ConvertBytesToStr(size int64) string

ConvertBytesToStr convert size into string

func ConvertLVMBytesToNumeric

func ConvertLVMBytesToNumeric(lvmbyte string) (int64, error)

func ConvertNumericToLVMBytes

func ConvertNumericToLVMBytes(num int64) string

func GenerateResourceName added in v0.3.5

func GenerateResourceName(substrs []string, addDatetime, addUuid bool, maxLen int) string

Return K8S compatible resource name using substrs and settings

e.g. sub1-sub2-20200101-01-f34rret4

func GetNamespace

func GetNamespace() string

GetNamespace get Namespace from env, else it returns error

func GetNodeName

func GetNodeName() string

GetNodeName gets the node name from env, else returns an error

func GetRFC3339LocalTime added in v0.3.5

func GetRFC3339LocalTime() string

func LogGRPC

func LogGRPC(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

LogGRPC log grpc all info

func NumericToLVMBytes

func NumericToLVMBytes(bytes int64) int64

func ParseBytes

func ParseBytes(sizeStr string) (int64, error)

ParseBytes parse size from string into bytes

func PrettyPrintJSON added in v0.3.5

func PrettyPrintJSON(v interface{})

PrettyPrintJSON for debug

func RemoveStringItem

func RemoveStringItem(items []string, itemToDelete string) []string

RemoveStringItem removes a string from a slice

func RunWithLease

func RunWithLease(ns string, identity string, lockName string, runFunc func(ctx context.Context)) error

RunWithLease run a process with acquired leader lease. It's a blocking function

func SanitizeName

func SanitizeName(name string) string

SanitizeName sanitizes the provided string so it can be consumed by leader election library copy from github.com/kubernetes-csi/csi-lib-utils/leaderelection

func WriteDataIntoSysFSFile

func WriteDataIntoSysFSFile(content, sysFilePath string) error

Types

type PCIDiskInfo

type PCIDiskInfo struct {
	// contains filtered or unexported fields
}

PCIDiskInfo struct

func (*PCIDiskInfo) IsNVMe

func (d *PCIDiskInfo) IsNVMe() bool

IsNVMe check if it's a nvme or not

type Route added in v0.3.5

type Route struct {
	Name        string
	Method      string
	Pattern     string
	HandlerFunc http.HandlerFunc
}

Route defines a rest api

Directories

Path Synopsis
Design for copy data from source PVC to destination PVC, continuously push statue into status channel for notifications
Design for copy data from source PVC to destination PVC, continuously push statue into status channel for notifications

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL