utils

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version is the current version of Velero, set by the go linker's -X flag at build time.
	Version string
	// GitSHA is the actual commit that is being built, set by the go linker's -X flag at build time.
	GitSHA string
)
View Source
var (
	// Rand is used for a random generator exclusively for this go module
	Rand = rand.New(rand.NewSource(time.Now().UTC().UnixNano()))
)

Functions

func Authenticate

func Authenticate(pc **gophercloud.ProviderClient, service string, config map[string]string, log logrus.FieldLogger) error

Authenticate to OpenStack and write client result to **pc

func CompareMicroversions

func CompareMicroversions(operator, want, have string) (bool, error)

CompareMicroversions compares two microversions using operators: lte: less than or equal gte: greater than or equal

func DurationToSeconds

func DurationToSeconds(str string) (int, error)

DurationToSeconds parses the string into a time.Duration format and returns seconds in int format

func EnsureDeleted

func EnsureDeleted(deleteFunc, checkFunc, resetFunc func() error, timeout int, delay int) error

EnsureDeleted ensures that the resource is deleted, resets the resource status if it's in error state and tries again until the timeout

func GetConf

func GetConf(config map[string]string, key, fallback string) string

GetConf gets a value from a config map or fallbacks to default value

func GetEnv

func GetEnv(key, fallback string) string

GetEnv gets value from environment variable or fallbacks to default value This snippet is from https://stackoverflow.com/a/40326580/3323419

func Merge

func Merge(args ...map[string]string) map[string]string

Merge merges maps. If more than one given map with the same key, then the one that is later in the argument sequence takes precedence

func ReplaceAccount

func ReplaceAccount(account, path string, prefixes []string) string

ReplaceAccount replaces an endpoint account part with a new account value

func SliceContains

func SliceContains[T comparable](elems []T, e T) bool

SliceContains checks whether a slice of comparable type contains an element

func WaitForStatus

func WaitForStatus(statuses []string, timeout int, checkFunc func() (string, error)) error

WaitForStatus wait until the resource status satisfies the expected statuses

Types

type ErrStatus

type ErrStatus struct {
	Status string
}

ErrStatus is used to indicate that a resource has unexpected Status

func (ErrStatus) Error

func (e ErrStatus) Error() string

Error satisfies golang error interface

Jump to

Keyboard shortcuts

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