utils

package
v0.0.0-...-c06f640 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OneKB = 1024
	OneMB = 1024 * 1024
	OneGB = 1024 * 1024 * 1024
)

Variables

View Source
var ErrNotInKubernetesEnv = errors.New("not running in Kubernetes environment")
View Source
var PublicLogMarker = zap.Bool("public", true)
View Source
var Version = "unknown"

Functions

func AcquireUpToMax

func AcquireUpToMax(ctx context.Context, currentProcessing *semaphore.Weighted) (uint32, error)

func AddFileToZip

func AddFileToZip(filePath, folderPath string, zipWriter *zip.Writer) error

func Close

func Close(closer func() error)

func ClosePreservingError

func ClosePreservingError(errPtr *error, closer io.Closer)

func ConvertISO8601Duration

func ConvertISO8601Duration(durationStr string) (time.Duration, error)

func CreateDirectory

func CreateDirectory(directoryPath string, permissions os.FileMode) error

func EffectiveEnvironment deprecated

func EffectiveEnvironment(icmsEnvironment, spotEnvironment string) string

EffectiveEnvironment returns the environment to use, preferring icmsEnvironment over spotEnvironment.

Deprecated: Configs now normalize in setup (ICMSEnvironment is set from SpotEnvironment when unset). Use the config's ICMSEnvironment field after setup instead of calling this.

func ExitReason

func ExitReason(err error)

func GetDirectorySize

func GetDirectorySize(dir string) (int64, error)

Utility function to get the size of a directory.

func GetWriteBufferSize

func GetWriteBufferSize(conn net.Conn) int

func LevelFromEnv

func LevelFromEnv() zap.AtomicLevel

LevelFromEnv reads from env LOG_LEVEL and defaults to INFO

func MultipartReadToBuffer

func MultipartReadToBuffer(src io.Reader, dst chan<- *bytebufferpool.ByteBuffer, maxPartSize int64) (int64, error)

Read content from reader into buffer and output them into a channel.

func NewProductionLogger

func NewProductionLogger() *logs.ZapLogger

func PortSafeUrl

func PortSafeUrl(uri string) (*url.URL, error)

PortSafeUrl adds port 80 or 443 to http(s) urls for use with tcp or grpc dialers

func SanitizePath

func SanitizePath(path string) string

func SleepWithContext

func SleepWithContext(ctx context.Context, d time.Duration)

SleepWithContext https://stackoverflow.com/a/69291047

func StringToDurationHookFunc

func StringToDurationHookFunc() mapstructure.DecodeHookFunc

func ZipFolder

func ZipFolder(folderPath string, target io.Writer) error

Types

type CloserFunc

type CloserFunc func() error

func (CloserFunc) Close

func (f CloserFunc) Close() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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