Documentation ¶
Overview ¶
Package utils to provide utils for CSI
Index ¶
- Constants
- Variables
- func AtoiWithDefault(s string, defaultResult int) int
- func CheckExistCode(err error, checkExitCode []string) error
- func ChmodFsPermission(ctx context.Context, targetPath, fsPermission string)
- func Contains[T comparable](sources []T, target T) bool
- func ConvertMapToStruct[T any](params map[string]any) (*T, error)
- func CopyMap(srcMap interface{}) map[string]interface{}
- func CreateSymlink(ctx context.Context, source string, target string) error
- func Errorf(ctx context.Context, format string, a ...interface{}) error
- func Errorln(ctx context.Context, msg string) error
- func ExecShellCmdFilterLog(ctx context.Context, format string, args ...interface{}) (string, error)
- func GetAccessModeType(accessMode csi.VolumeCapability_AccessMode_Mode) string
- func GetAlua(ctx context.Context, alua map[string]interface{}, host string) map[string]interface{}
- func GetCertFromSecret(ctx context.Context, SecretName, SecretNamespace string) ([]byte, error)
- func GetDtreeSharePath(name string) string
- func GetFSSharePath(name string) string
- func GetFSSnapshotName(name string) string
- func GetFileSystemName(name string) string
- func GetForbiddenMultipath(ctx context.Context, multipathConfig map[string]interface{}, ...) []string
- func GetFusionStorageLunName(name string) string
- func GetFusionStorageSnapshotName(name string) string
- func GetHostName(ctx context.Context) (string, error)
- func GetLunUniqueId(ctx context.Context, protocol string, lun map[string]interface{}) (string, error)
- func GetOriginSharePath(name string) string
- func GetPasswordFromSecret(ctx context.Context, SecretName, SecretNamespace string) (string, error)
- func GetProductVersion(systemInfo map[string]interface{}) (string, error)
- func GetRequiredMultipath(ctx context.Context, multipathConfig map[string]interface{}, ...) ([]string, error)
- func GetSharePath(name string) string
- func GetSnapshotName(name string) string
- func GetValueByRegexp(sourceString string, patternString string, valueIndex int) string
- func IgnoreExistCode(err error, checkExitCode []string) error
- func IsCapacityAvailable(volumeSizeBytes int64, allocationUnitBytes int64) bool
- func IsContain[T constants.FileType | string](target T, list []T) bool
- func IsDebugLog(method, url string, debugLogMap map[string]map[string]bool, ...) bool
- func IsPathSymlink(targetPath string) (symlink bool, err error)
- func IsPathSymlinkWithTimeout(targetPath string, duration time.Duration) (bool, error)
- func IsSupportFeature(features map[string]int, feature string) bool
- func MaskConnSensitiveInfo(info interface{}) string
- func MaskSensitiveInfo(info interface{}) string
- func MergeMap(args ...map[string]interface{}) map[string]interface{}
- func NewContextWithRequestID() context.Context
- func ParseIntWithDefault(s string, base int, bitSize int, defaultResult int64) int64
- func RandomInt(n int) int
- func ReadWwnFile(ctx context.Context, volumeId string) (string, error)
- func RecoverPanic(ctx context.Context)
- func ReflectCall(obj interface{}, method string, args ...interface{}) []reflect.Value
- func RemoveDir(filePath, dir string)
- func RemoveString(slice []string, s string) []string
- func RemoveSymlink(ctx context.Context, target string) error
- func RemoveWwnFile(ctx context.Context, volumeId string) error
- func ResCodeExist(code interface{}) bool
- func RoundUpSize(volumeSizeBytes int64, allocationUnitBytes int64) int64
- func SplitSnapshotId(snapshotId string) (string, string, string)
- func SplitVolumeId(volumeId string) (string, string)
- func StrToBool(ctx context.Context, str string) bool
- func StringContain(strPrefix string, stringList []string) bool
- func ToStringSafe(i interface{}) string
- func ToStringWithFlag(i interface{}) (string, bool)
- func TransK8SCapacity(volumeSizeSectors, allocationUnitBytes int64) int64
- func TransToInt(v interface{}) (int, error)
- func TransToIntStrict(ctx context.Context, val interface{}) (int, error)
- func TransVolumeCapacity(size int64, unit int64) int64
- func WaitUntil(f func() (bool, error), timeout time.Duration, interval time.Duration) error
- func WriteWWNFile(ctx context.Context, wwn, volumeId string) error
- func WriteWWNFileIfNotExist(ctx context.Context, wwn, volumeId string) error
- type Semaphore
- type Volume
- type VolumeMetrics
Constants ¶
const ( DoradoV6Prefix = "V600" OceanStorV5Prefix = "V500" )
Variables ¶
var ExecShellCmd = func(ctx context.Context, format string, args ...interface{}) (string, error) { return execShellCmdTimeout(ctx, execShellCmd, format, false, args...) }
ExecShellCmd execs the command without filters the result log
Functions ¶
func AtoiWithDefault ¶
AtoiWithDefault Atoi without error
func CheckExistCode ¶
CheckExistCode if the error code exist in ExitCode, return err
func ChmodFsPermission ¶
ChmodFsPermission used for change target path permission
func Contains ¶
func Contains[T comparable](sources []T, target T) bool
Contains sources contains target
func ConvertMapToStruct ¶
ConvertMapToStruct converts map[string]any to struct
func CreateSymlink ¶
CreateSymlink between source and target
func ExecShellCmdFilterLog ¶
ExecShellCmdFilterLog execs the command and filters the result log
func GetAccessModeType ¶
func GetAccessModeType(accessMode csi.VolumeCapability_AccessMode_Mode) string
func GetCertFromSecret ¶
GetCertFromSecret used to get cert from secret
func GetDtreeSharePath ¶
func GetFSSharePath ¶
func GetFSSnapshotName ¶
func GetFileSystemName ¶
func GetForbiddenMultipath ¶
func GetForbiddenMultipath(ctx context.Context, multipathConfig map[string]interface{}, backendConfigs []map[string]interface{}) []string
GetForbiddenMultipath used to get forbidden multipath service by configuration and backend info.
func GetFusionStorageLunName ¶
func GetLunUniqueId ¶
func GetOriginSharePath ¶
func GetPasswordFromSecret ¶
GetPasswordFromSecret used to get password from secret
func GetProductVersion ¶
GetProductVersion is to get the oceanStorage version by get info from the system
func GetRequiredMultipath ¶
func GetRequiredMultipath(ctx context.Context, multipathConfig map[string]interface{}, backendConfigs []map[string]interface{}) ([]string, error)
GetRequiredMultipath used to get required multipath service by configuration and backend info.
func GetSharePath ¶
func GetSnapshotName ¶
func GetValueByRegexp ¶
GetValueByRegexp used to get value by regular expression
func IgnoreExistCode ¶
IgnoreExistCode if the error code exist in ExitCode, return nil
func IsCapacityAvailable ¶
IsCapacityAvailable indicates whether the volume size is an integer multiple of 512.
func IsContain ¶
IsContain used to determine whether list contains target. type support FileType, string now and can be extended
func IsDebugLog ¶
func IsDebugLog(method, url string, debugLogMap map[string]map[string]bool, regLogs map[string][]string) bool
IsDebugLog is used to determine whether debug log are required.
func IsPathSymlink ¶
IsPathSymlink checks weather this targetPath is symlink
func IsPathSymlinkWithTimeout ¶
IsPathSymlinkWithTimeout checks weather this targetPath is symlink
func MaskConnSensitiveInfo ¶
func MaskConnSensitiveInfo(info interface{}) string
func MaskSensitiveInfo ¶
func MaskSensitiveInfo(info interface{}) string
func NewContextWithRequestID ¶
NewContextWithRequestID new a context
func ParseIntWithDefault ¶
ParseIntWithDefault parseInt without error
func ReadWwnFile ¶
ReadWwnFile read the wwn info file.
func ReflectCall ¶
func RemoveString ¶
RemoveString returns a newly created []string that contains all items from slice that are not equal to s.
func RemoveSymlink ¶
RemoveSymlink from target path
func RemoveWwnFile ¶
RemoveWwnFile remove the wwn info file.
func ResCodeExist ¶
func ResCodeExist(code interface{}) bool
ResCodeExist if code not 0 then return error
func RoundUpSize ¶
func SplitVolumeId ¶
func StringContain ¶
StringContain return the string prefix whether in the target string list
func ToStringSafe ¶
func ToStringSafe(i interface{}) string
ToStringSafe convert to string with default "" safe
func ToStringWithFlag ¶
ToStringWithFlag if success return true, or return false
func TransK8SCapacity ¶
TransK8SCapacity trans volume size from Sector to Bytes
func TransToInt ¶
TransToInt is to trans different type to int type.
func TransToIntStrict ¶
TransToIntStrict only trans int type.
func TransVolumeCapacity ¶
func WriteWWNFile ¶
WriteWWNFile write the wwn info for use in unstage call.
Types ¶
type Semaphore ¶
type Semaphore struct {
// contains filtered or unexported fields
}
func NewSemaphore ¶
func (*Semaphore) AvailablePermits ¶
func (*Semaphore) GetChannel ¶
type Volume ¶
type Volume interface { GetVolumeName() string GetLunWWN() (string, error) SetLunWWN(string) SetSize(int64) GetSize() (int64, error) SetDTreeParentName(string) GetDTreeParentName() string GetFilesystemMode() string SetFilesystemMode(string) GetID() string SetID(string) }
Volume interface is a perform operations on volume object
type VolumeMetrics ¶
type VolumeMetrics struct { Available *resource.Quantity Capacity *resource.Quantity InodesUsed *resource.Quantity Inodes *resource.Quantity InodesFree *resource.Quantity Used *resource.Quantity }
func GetVolumeMetrics ¶
func GetVolumeMetrics(path string) (*VolumeMetrics, error)
Directories ¶
Path | Synopsis |
---|---|
Package concurrent used to process concurrent request
|
Package concurrent used to process concurrent request |
Package k8sutils provides Kubernetes utilities
|
Package k8sutils provides Kubernetes utilities |
Package log output logged entries to respective logging hooks
|
Package log output logged entries to respective logging hooks |
Package notify offers a wait and notify mechanism
|
Package notify offers a wait and notify mechanism |
Package taskflow offers task flow operations
|
Package taskflow offers task flow operations |
Package version offers version inits options
|
Package version offers version inits options |