Documentation ¶
Overview ¶
Package utils contains miscellaneous utility code
Index ¶
- func CloseWarn(closer io.Closer, err error) error
- func CollateOptions[T any](defaults T, optFns ...func(*T)) T
- func CollateOptionsWithDefaults[T any](optFns ...func(*T)) T
- func ExpandAndVerifyExists(filePath string, description string) (string, error)
- func FileExists(file string) (bool, error)
- func Interactive() bool
- func IsIPV4Address(addr string) bool
- func JoinSelector(labels map[string]string) string
- func Not[T any](fn func(T) bool) func(T) bool
- func Nullable[T any](val T) *T
- func OverrideEnvVarForTest(t *testing.T, variable string, value string, test func())
- func PathToRunningThelmaExecutable() (string, error)
- func QuoteJoin(strs []string) string
- func TerminalWidth() int
- func UnsetEnvVarForTest(t *testing.T, variable string, test func())
- func UnsetOrEmpty[T comparable](val *T) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseWarn ¶ added in v1.0.41
CloseWarn gracefully handle Close() error when a prior error is more salient
func CollateOptions ¶ added in v1.0.41
func CollateOptions[T any](defaults T, optFns ...func(*T)) T
CollateOptions utility for collating option functions into a struct
func CollateOptionsWithDefaults ¶ added in v1.0.44
func CollateOptionsWithDefaults[T any](optFns ...func(*T)) T
CollateOptionsWithDefaults given a struct annotated with `default` annotations from https://github.com/mcuadros/go-defaults, set defaults and call CollateOptions set utility for collating option functions into a struct
func ExpandAndVerifyExists ¶
ExpandAndVerifyExists Expand relative path to absolute, and make sure it exists. This is necessary for many arguments because Helmfile assumes paths are relative to helmfile.yaml and we want them to be relative to CWD.
func FileExists ¶ added in v0.0.29
FileExists returns true if the file exists, false otherwise, and an error if an error occurs
func Interactive ¶ added in v0.0.29
func Interactive() bool
Interactive returns true if Thelma is running in an interactive shell, false otherwise. Useful for detecting if Thelma is running in CI pipelines or on a dev laptop
func IsIPV4Address ¶ added in v0.0.24
IsIPV4Address returns true if addr is a valid ipv4 address
func JoinSelector ¶ added in v1.0.55
JoinSelector join map of label key-value pairs {"a":"b", "c":"d"} into selector string "a=b,c=d"
func Nullable ¶ added in v0.0.63
func Nullable[T any](val T) *T
Nullable is a utility to turn a value into a pointer to that value
func OverrideEnvVarForTest ¶ added in v1.0.103
func PathToRunningThelmaExecutable ¶ added in v1.0.41
PathToRunningThelmaExecutable returns the path to the currently-running Thelma binary executable. Note that this could be _outside_ Thelma's configured root directory (i.e., not ~/.thelma/releases/current/bin). For example:
- During initial installation, Thelma is run out of Thelma release archive that is unpacked into a temp directory.
- In CI pipelines, Thelma is run out of a well-known path on its Docker image /thelma/bin/thelma
- When Thelma is built locally during development, it is run out of the build output directory, ./output/bin/thelma
Also note that this might not be a running Thelma binary at all, for example if this code is executed from a unit test (command will be the `go` executable)
func QuoteJoin ¶ added in v0.0.24
QuoteJoin quotes all strings in a slice and joins them with `, ` eg. QuoteJoin([]string{`a`, `b`, `c`}, `, `) -> `"a", "b", "c"`
func TerminalWidth ¶ added in v1.0.44
func TerminalWidth() int
TerminalWidth returns width of the current interactive terminal. Returns 0 if shell is not interactive or if terminal width could not be detected
func UnsetEnvVarForTest ¶ added in v1.1.53
func UnsetOrEmpty ¶ added in v1.0.54
func UnsetOrEmpty[T comparable](val *T) bool
Types ¶
This section is empty.
Directories ¶
Path | Synopsis |
---|---|
Package pool contains a generic implementation of the worker pool pattern for concurrent processing
|
Package pool contains a generic implementation of the worker pool pattern for concurrent processing |