helpers

package
v0.6.39 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: AGPL-3.0, Apache-2.0, MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvPrefix = "PLRL"
)

Variables

This section is empty.

Functions

func CreateTempDirOrDie

func CreateTempDirOrDie(dir, pattern string) string

CreateTempDirOrDie - creates a temporary directory in the specified dir with the given pattern. If dir is an empty string, the default temporary directory for the OS will be used. Panics if the directory cannot be created.

func DynamicBackgroundPollUntilContextCancel

func DynamicBackgroundPollUntilContextCancel(ctx context.Context, getInterval func() time.Duration, syncFirstRun bool, callback wait.ConditionWithContextFunc) (err error)

DynamicBackgroundPollUntilContextCancel spawns a new goroutine that runs the condition function on interval. If syncFirstRun is set to true, it will execute the condition function synchronously first and then start polling. Since error is returned synchronously, the only way to check for it is to use syncFirstRun. Background poller does not sync errors. It can be stopped externally by cancelling the provided context.

func DynamicPollUntilContextCancel

func DynamicPollUntilContextCancel(
	ctx context.Context,
	intervalFunc func() time.Duration,
	callback wait.ConditionWithContextFunc,
) error

func EnsureDirOrDie

func EnsureDirOrDie(dir string)

EnsureDirOrDie - ensures that the specified directory exists. If the directory does not exist, it will be created with the specified permissions. Panics if the directory cannot be created.

func EnsureFileOrDie

func EnsureFileOrDie(file string, content *string) string

func Exists

func Exists(file string) bool

func GetEnv

func GetEnv(key, fallback string) string

GetEnv - Lookup the environment variable provided and set to default value if variable isn't found

func GetPluralEnv

func GetPluralEnv(key, fallback string) string

GetPluralEnv - Lookup the plural environment variable. It has to be prefixed with EnvPrefix. If variable with the provided key is not found, fallback will be used.

func GetPluralEnvBool

func GetPluralEnvBool(key string, fallback bool) bool

GetPluralEnvBool - Lookup the plural environment variable. It has to be prefixed with EnvPrefix. If variable with the provided key is not found, fallback will be used.

func GetPluralEnvDuration

func GetPluralEnvDuration(key string, fallback time.Duration) time.Duration

GetPluralEnvDuration retrieves a duration from an environment variable prefixed with EnvPrefix. Returns the parsed duration or a fallback if parsing fails or the environment variable is not set.

func GetPluralEnvSlice

func GetPluralEnvSlice(key string, fallback []string) []string

GetPluralEnvSlice - Lookup the plural environment variable. It has to be prefixed with EnvPrefix. If variable with the provided key is not found, fallback will be used.

func NewAuthorizationBearerTransport

func NewAuthorizationBearerTransport(token string) http.RoundTripper

func NewAuthorizationTokenTransport

func NewAuthorizationTokenTransport(token string) http.RoundTripper

func ParseIntOrDie

func ParseIntOrDie(value string) int

Types

type AuthorizationBearerTransport

type AuthorizationBearerTransport struct {
	// contains filtered or unexported fields
}

func (*AuthorizationBearerTransport) RoundTrip

func (in *AuthorizationBearerTransport) RoundTrip(req *http.Request) (*http.Response, error)

type AuthorizationTokenTransport

type AuthorizationTokenTransport struct {
	// contains filtered or unexported fields
}

func (*AuthorizationTokenTransport) RoundTrip

func (in *AuthorizationTokenTransport) RoundTrip(req *http.Request) (*http.Response, error)

type Buffer

type Buffer struct {
	*bytes.Buffer
	// contains filtered or unexported fields
}

Buffer is an internal buffer wrapper to ensure that Write/Read operations are thread-safe and cannot be run at the same time. It also starts a small goroutine that notifies about buffer size changes through channel. See Updated method for more information.

func NewBuffer

func NewBuffer() *Buffer

func (*Buffer) Len

func (b *Buffer) Len() int

Len overrides bytes.Buffer method. It ensures thread-safe execution.

func (*Buffer) Next

func (b *Buffer) Next(n int) []byte

Next overrides bytes.Buffer method. It ensures thread-safe execution.

func (*Buffer) ReadBytes

func (b *Buffer) ReadBytes(delim byte) (line []byte, err error)

ReadBytes overrides bytes.Buffer method. It ensures thread-safe execution.

func (*Buffer) String

func (b *Buffer) String() string

String overrides bytes.Buffer method. It ensures thread-safe execution.

func (*Buffer) Updated

func (b *Buffer) Updated() chan struct{}

Updated returns a channel that receives signal every time buffer size gets updated.

func (*Buffer) Write

func (b *Buffer) Write(p []byte) (n int, err error)

Write implements io.Writer interface. It ensures thread-safe execution.

type FetchClient

type FetchClient interface {
	Tarball(url string) (string, error)
}

func Fetch

func Fetch(options ...FetchOption) FetchClient

type FetchOption

type FetchOption func(*fetchClient)

func FetchToDir

func FetchToDir(destination string) FetchOption

func FetchWithBearer

func FetchWithBearer(token string) FetchOption

func FetchWithTimeout

func FetchWithTimeout(timeout time.Duration) FetchOption

func FetchWithToken

func FetchWithToken(token string) FetchOption

type FileClient

type FileClient interface {
	Create(path, content string, perm os.FileMode) error
}

func File

func File() FileClient

Jump to

Keyboard shortcuts

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