utils

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CSIQuotaIDPrefix = "CSI_QUOTA_ID:"

CSIQuotaIDPrefix is the CSI tag for quota id stored in the export's description field set by csi driver

View Source
var ExportConflictMessagePattern = regexp.MustCompile(fmt.Sprintf("^Export rules (\\d+) and (\\d+) conflict on '(.+)'$"))

ExportConflictMessagePattern is the regex pattern that identifies the error message of export conflict

View Source
var NodeIDPattern = regexp.MustCompile(fmt.Sprintf("^(.+)%s(.+)%s(.+)$", NodeIDSeparator, NodeIDSeparator))

NodeIDPattern is the regex pattern that identifies the NodeID

View Source
var NodeIDSeparator = "=#=#="

NodeIDSeparator is the separator that separates node name and IP Address

View Source
var QuotaIDPattern = regexp.MustCompile(fmt.Sprintf("^%s(.*)", CSIQuotaIDPrefix))

QuotaIDPattern the regex pattern that identifies the quota id set in the export's description field set by csi driver

View Source
var VolumeIDPattern = regexp.MustCompile(fmt.Sprintf("^(.+)%s(\\d+)%s(.+)$", VolumeIDSeparator, VolumeIDSeparator))

VolumeIDPattern is the regex pattern that identifies the quota id set in the export's description field set by csi driver

View Source
var VolumeIDSeparator = "=_=_="

VolumeIDSeparator is the separator that separates volume name and export ID (two components that a normalized volume ID is comprised of)

Functions

func CombineTwoStrings

func CombineTwoStrings(s1 string, s2 string, sign string) string

CombineTwoStrings combines two string variables isolated by defined sign

func ConfigureLogger

func ConfigureLogger(debugEnabled bool) context.Context

ConfigureLogger sets log level for the logger

func GetAccessMode

GetAccessMode extracts the access mode from the given *csi.ControllerPublishVolumeRequest instance

func GetExportIDFromConflictMessage

func GetExportIDFromConflictMessage(message string) int

GetExportIDFromConflictMessage returns the export id of the export which is creating or just created when there occurs a conflict

func GetFQDNByIP

func GetFQDNByIP(ip string) (string, error)

GetFQDNByIP returns the FQDN based on the parsed ip address

func GetIsiPathFromExportPath

func GetIsiPathFromExportPath(exportPath string) string

GetIsiPathFromExportPath returns isiPath based on the export path

func GetNewUUID

func GetNewUUID() (string, error)

GetNewUUID generates a UUID

func GetNormalizedVolumeID

func GetNormalizedVolumeID(volName string, exportID int, accessZone string) string

GetNormalizedVolumeID combines volume name (i.e. the directory name), export ID and access zone to form the normalized volume ID e.g. k8s-e89c9d089e + 19 + csi0zone => k8s-e89c9d089e=_=_=19=_=_=csi0zone

func GetOwnFQDN

func GetOwnFQDN() (string, error)

GetOwnFQDN returns the FQDN of the node or controller itself

func GetPathForVolume

func GetPathForVolume(isiPath, volName string) string

GetPathForVolume gets the volume full path by the combination of isiPath and volumeName

func GetQuotaIDFromDescription

func GetQuotaIDFromDescription(export isi.Export) (string, error)

GetQuotaIDFromDescription extracts quota id from the description field of export

func GetQuotaIDWithCSITag

func GetQuotaIDWithCSITag(quotaID string) string

GetQuotaIDWithCSITag formats a given quota id with the CSI tag, e.g. AABpAQEAAAAAAAAAAAAAQA0AAAAAAAAA -> CSI_QUOTA_ID:AABpAQEAAAAAAAAAAAAAQA0AAAAAAAAA

func GetVolumeNameFromExportPath

func GetVolumeNameFromExportPath(exportPath string) string

GetVolumeNameFromExportPath returns volume name based on the export path

func IsStringInSlice

func IsStringInSlice(str string, list []string) bool

IsStringInSlice checks if a string is an element of a string slice

func IsStringInSlices

func IsStringInSlices(str string, list ...[]string) bool

IsStringInSlices checks if a string is an element of a any of the string slices

func LogMap

func LogMap(mapName string, m map[string]string)

LogMap logs the key-value entries of a given map

func ParseBooleanFromContext

func ParseBooleanFromContext(ctx context.Context, key string) bool

ParseBooleanFromContext parses an environment variable into a boolean value. If an error is encountered, default is set to false, and error is logged

func ParseNodeID added in v1.4.0

func ParseNodeID(nodeID string) (string, string, string, error)

ParseNodeID parses NodeID to node name, node FQDN and IP address using pattern '^(.+)=#=#=(.+)=#=#=(.+)'

func ParseNormalizedVolumeID

func ParseNormalizedVolumeID(volID string) (string, int, string, error)

ParseNormalizedVolumeID parses the volume ID (following the pattern '^(.+)=_=_=(d+)=_=_=(.+)$') to extract the volume name, export ID and access zone that make up the volume ID e.g. k8s-e89c9d089e=_=_=19=_=_=csi0zone => k8s-e89c9d089e, 19, csi0zone

func ParseUintFromContext added in v1.1.0

func ParseUintFromContext(ctx context.Context, key string) uint

ParseUintFromContext parses an environment variable into a uint value. If an error is encountered, default is set to 0, and error is logged

func RemoveExistingCSISockFile

func RemoveExistingCSISockFile() error

RemoveExistingCSISockFile When the sock file that the gRPC server is going to be listening on already exists, error will be thrown saying the address is already in use, thus remove it first

func RemoveStringFromSlice

func RemoveStringFromSlice(str string, list []string) []string

RemoveStringFromSlice returns a slice that is a copy of the input "list" slice with the input "str" string removed

func RemoveStringsFromSlice

func RemoveStringsFromSlice(filters []string, list []string) []string

RemoveStringsFromSlice generates a slice that is a copy of the input "list" slice with elements from the input "strs" slice removed

func RemoveSurroundingQuotes

func RemoveSurroundingQuotes(s string) string

RemoveSurroundingQuotes removes the surrounding double quotes of a given string (if there are no surrounding quotes, do nothing)

Types

This section is empty.

Jump to

Keyboard shortcuts

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