utils

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotLVMByteNum = errors.New("LVM byte format unrecognised")
)

Functions

func AddUniqueStringItem

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

AddUniqueStringItem add a string from a slice without duplicate

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 added in v0.0.2

func ConvertLVMBytesToNumeric(lvmbyte string) (int64, error)

func ConvertNumericToLVMBytes added in v0.0.2

func ConvertNumericToLVMBytes(num int64) string

func GetNamespace added in v0.1.10

func GetNamespace() string

GetNamespace get Namespace from env, else it returns error

func GetNodeName added in v0.1.10

func GetNodeName() string

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

func GetPCIDisks

func GetPCIDisks(cmdExec exechelper.Executor) (map[string]*PCIDiskInfo, error)

GetPCIDisks gets pci disks info on the local node

func LogGRPC

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

LogGRPC log grpc all info

func LogREST

func LogREST(inner http.Handler, name string) http.Handler

LogREST log rest api call info

func NumericToLVMBytes added in v0.0.2

func NumericToLVMBytes(bytes int64) int64

func ParseBytes

func ParseBytes(sizeStr string) (int64, error)

ParseBytes parse size from string into bytes

func PrettyPrintJSON

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

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

Jump to

Keyboard shortcuts

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