Documentation ¶
Index ¶
- Constants
- Variables
- func ByteCountSI(b int64) string
- func Contains(v string, l []string) bool
- func ContainsList(v []string, l []string) bool
- func ContainsPrefix(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 GetEnv(key, fallback string) string
- func GetVersionIncrement(version string) (string, error)
- func LatestSemverVersion(versions []string) (string, error)
- func ListKeys(m map[string]any) []string
- func LoadYAML(path string, data interface{}) error
- func LoadYAMLFromReader(reader io.Reader, data interface{}) error
- func MaxChars(slice string, max int) string
- func MergeStringMaps(list ...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 Sorted(slice []string) []string
- func TempDirName() string
- func ToMap(slice []string) (map[string]string, error)
- func TouchFile(path string) error
- func Unique(slice []string) []string
- func VersionLessThan(version string, other string) (bool, error)
- func WaitForFile(ctx context.Context, path string, timeout time.Duration) error
- func WriteYAML(path string, data interface{}) error
- func WriteYAMLToWriter(writer io.Writer, data interface{}) 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 ContainsPrefix ¶ added in v0.4.0
ContainsPrefix checks a list has a value with the prefixes
func GetEnv ¶ added in v0.3.24
GetEnv returns the value of an environment variable or a default value if not set
func GetVersionIncrement ¶ added in v0.4.0
GetVersionIncrement returns either an error or the version increment
func LatestSemverVersion ¶ added in v0.4.0
LatestSemverVersion returns the latest semver version from a list of versions.
func LoadYAMLFromReader ¶ added in v0.4.0
LoadYAMLFromReader loads a yaml document from a io reader
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 VersionLessThan ¶ added in v0.4.0
VersionLessThan returns either an error a bool indicating if the version is greater than the other
func WaitForFile ¶
WaitForFile waits for a file to exist or times out
func WriteYAMLToWriter ¶ added in v0.4.0
WriteYAMLToWriter writes a yaml document to a writer