Documentation ¶
Index ¶
- Constants
- Variables
- func ByteCountSI(b int64) string
- func Contains(v string, l []string) bool
- func ContainsList(v []string, l []string) bool
- func DirExists(path string) (bool, error)
- func DirSize(path string) (int64, error)
- func Download(ctx context.Context, source, destination string) error
- func FileExists(filename string) (bool, error)
- func GetTxtFunc() map[string]any
- func HumanDuration(d time.Duration) string
- func IsLabelSelectorMatch(source map[string]string, selector metav1.LabelSelector) (bool, error)
- func IsSelectorMatch(selector terraformv1alphav1.Selector, ...) (bool, error)
- func MergeStringMaps(a, b map[string]string) map[string]string
- func Random(length int) string
- func RandomWithCharset(length int, charset string) string
- func Retry(ctx context.Context, attempts int, jitter bool, minInterval time.Duration, ...) error
- func RetryWithTimeout(ctx context.Context, timeout, interval time.Duration, retryFn RetryFunc) error
- func Sleep(ctx context.Context, sleep time.Duration) bool
- func SortSemverVersions(versions []string) ([]string, error)
- func TempDirName() string
- func Template(main string, data interface{}) ([]byte, error)
- func ToHCL(data interface{}) (string, error)
- func TouchFile(path string) error
- func WaitForFile(ctx context.Context, path string, timeout time.Duration) error
- func YAMLDocuments(reader io.Reader) ([]string, error)
- type RetryFunc
Constants ¶
const (
// DefaultCharSet is the default charset to use
DefaultCharSet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
)
const (
// MaxAttempts is the max attempts
MaxAttempts = 99999999
)
Variables ¶
var ( // ErrCancelled indicates the operation was cancelled ErrCancelled = errors.New("operation cancelled") // ErrReachMaxAttempts indicates we hit the limit ErrReachMaxAttempts = errors.New("reached max attempts") )
Functions ¶
func ByteCountSI ¶
ByteCountSI returns the number of bytes in the given number of SI units.
func ContainsList ¶
ContainsList checks a list has a value in it
func GetTxtFunc ¶
GetTxtFunc returns a defaults list of methods for text templating
func HumanDuration ¶
HumanDuration returns a more human friendly duration
func IsLabelSelectorMatch ¶
IsLabelSelectorMatch is used to check if the selectors matches the labels.
func IsSelectorMatch ¶
func IsSelectorMatch( selector terraformv1alphav1.Selector, resourceLabels, namespaceLabels map[string]string) (bool, error)
IsSelectorMatch is used to check if the resource matches the selectors.
func MergeStringMaps ¶
MergeStringMaps merges maps together
func RandomWithCharset ¶
RandomWithCharset returns a random string of x charset
func Retry ¶
func Retry(ctx context.Context, attempts int, jitter bool, minInterval time.Duration, retryFn RetryFunc) error
Retry is used to retry an operation multiple times under a context. If the retryFn returns false with no error, the operation will be retried.
func RetryWithTimeout ¶
func RetryWithTimeout(ctx context.Context, timeout, interval time.Duration, retryFn RetryFunc) error
RetryWithTimeout creates a retry with a specific timeout
func SortSemverVersions ¶
SortSemverVersions sorts a list of semver versions in ascending order.
func WaitForFile ¶
WaitForFile waits for a file to exist or times out