util

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2019 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VolumeStackPrefix     = "volume-"
	ControllerServiceName = "controller"
	ReplicaServiceName    = "replica"

	BackupStoreTypeS3 = "s3"
	AWSAccessKey      = "AWS_ACCESS_KEY_ID"
	AWSSecretKey      = "AWS_SECRET_ACCESS_KEY"
	AWSEndPoint       = "AWS_ENDPOINTS"

	HostProcPath     = "/host/proc"
	ReplicaDirectory = "/replicas/"

	DefaultKubernetesTolerationKey = "kubernetes.io"
)

Variables

View Source
var (
	ConflictRetryInterval = 20 * time.Millisecond
	ConflictRetryCounts   = 100
)

Functions

func AddFinalizer

func AddFinalizer(name string, obj runtime.Object) error

func AreIdenticalTolerations added in v0.6.0

func AreIdenticalTolerations(oldTolerations, newTolerations map[string]v1.Toleration) bool

func Backoff

func Backoff(maxDuration time.Duration, timeoutMessage string, f func() (bool, error)) error

func CheckBackupType

func CheckBackupType(backupTarget string) (string, error)

func CheckDiskPathReplicaSubdirectory added in v0.6.2

func CheckDiskPathReplicaSubdirectory(diskPath string) (bool, error)

func CmdOutLines

func CmdOutLines(cmd *exec.Cmd, cancel <-chan interface{}) (<-chan string, <-chan error)

func ConfigBackupCredential

func ConfigBackupCredential(backupTarget string, credential map[string]string) error

func ConfigEnvWithCredential

func ConfigEnvWithCredential(backupTarget string, credentialSecret string, hasEndpoint bool, container *v1.Container) error

func ConvertSize

func ConvertSize(size interface{}) (int64, error)

func CopyReq

func CopyReq(req *http.Request) *http.Request

func CreateDiskPath added in v0.6.0

func CreateDiskPath(path string) error

func Execute

func Execute(binary string, args ...string) (string, error)

func ExecuteWithTimeout

func ExecuteWithTimeout(timeout time.Duration, binary string, args ...string) (string, error)

func ExecuteWithoutTimeout added in v0.6.0

func ExecuteWithoutTimeout(binary string, args ...string) (string, error)

func FilteredLoggingHandler added in v0.4.1

func FilteredLoggingHandler(filteredPaths map[string]struct{}, writer io.Writer, router http.Handler) http.Handler

func FinalizerExists

func FinalizerExists(name string, obj runtime.Object) bool

func FormatLocalTime

func FormatLocalTime(t time.Time, loc *time.Location) string

func FormatTimeZ

func FormatTimeZ(t time.Time) string

func FromMillis

func FromMillis(t int64) time.Time

func GetBackupID

func GetBackupID(backupURL string) (string, error)

func GetChecksumSHA512

func GetChecksumSHA512(data []byte) string

func GetLocalIPs

func GetLocalIPs() ([]string, error)

func GetRequiredEnv

func GetRequiredEnv(key string) (string, error)

func GetStringChecksum

func GetStringChecksum(data string) string

func IsKubernetesDefaultToleration added in v0.6.0

func IsKubernetesDefaultToleration(toleration v1.Toleration) bool

func LimitToPeriod

func LimitToPeriod(p, t [2]time.Time) [2]time.Time

func Now

func Now() string

func ParseLabels

func ParseLabels(labels []string) (map[string]string, error)

ParseLabels parses the provided Labels based on longhorn-engine's implementation: https://github.com/longhorn/longhorn-engine/blob/master/util/util.go

func ParseLocalTime

func ParseLocalTime(ts string, loc *time.Location) (time.Time, error)

func ParsePeriod

func ParsePeriod(s string, loc *time.Location) ([2]time.Time, error)

func ParseTime

func ParseTime(t string) (time.Time, error)

func ParseTimeZ

func ParseTimeZ(s string) (time.Time, error)

func RandomID

func RandomID() string

func RegisterShutdownChannel

func RegisterShutdownChannel(done chan struct{})

func RemoveFinalizer

func RemoveFinalizer(name string, obj runtime.Object) error

func RemoveHostDirectoryContent added in v0.3.3

func RemoveHostDirectoryContent(directory string) (err error)

func RetryOnConflictCause

func RetryOnConflictCause(fn func() (interface{}, error)) (obj interface{}, err error)

func RoundUpSize

func RoundUpSize(size int64) int64

func RunAsync added in v0.3.1

func RunAsync(wg *sync.WaitGroup, f func())

func SplitStringToMap

func SplitStringToMap(str, separator string) map[string]struct{}

func TimestampAfterTimeout

func TimestampAfterTimeout(ts string, timeout time.Duration) bool

func TolerationListToMap added in v0.6.0

func TolerationListToMap(tolerationList []v1.Toleration) map[string]v1.Toleration

func UUID

func UUID() string

func ValidateName

func ValidateName(name string) bool

func ValidateSnapshotLabels added in v0.6.0

func ValidateSnapshotLabels(labels map[string]string) (map[string]string, error)

func ValidateTags added in v0.6.0

func ValidateTags(inputTags []string) ([]string, error)

func WaitForAPI

func WaitForAPI(url string, timeout int) error

WaitForAPI timeout in second

func WaitForDevice

func WaitForDevice(dev string, timeout int) error

WaitForDevice timeout in second

Types

type DiskInfo

type DiskInfo struct {
	Fsid             string
	Path             string
	Type             string
	FreeBlock        int64
	TotalBlock       int64
	BlockSize        int64
	StorageMaximum   int64
	StorageAvailable int64
}

func GetDiskInfo

func GetDiskInfo(directory string) (info *DiskInfo, err error)

type MetadataConfig

type MetadataConfig struct {
	DriverName          string
	Image               string
	OrcImage            string
	DriverContainerName string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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