utils

package
v1.0.72 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2023 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package utils contains miscellaneous utility code

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseWarn added in v1.0.41

func CloseWarn(closer io.Closer, err error) error

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

func ExpandAndVerifyExists(filePath string, description string) (string, error)

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

func FileExists(file string) (bool, error)

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

func IsIPV4Address(addr string) bool

IsIPV4Address returns true if addr is a valid ipv4 address

func JoinSelector added in v1.0.55

func JoinSelector(labels map[string]string) string

JoinSelector join map of label key-value pairs {"a":"b", "c":"d"} into selector string "a=b,c=d"

func Not added in v1.0.44

func Not[T any](fn func(T) bool) func(T) bool

Not negates a single-argument predicate

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 PathToRunningThelmaExecutable added in v1.0.41

func PathToRunningThelmaExecutable() (string, error)

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

func QuoteJoin(strs []string) string

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 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

Jump to

Keyboard shortcuts

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