osutil

package
v0.0.0-...-f0f52ea Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PermissionDirectory      os.FileMode = 0755
	PermissionExecutableFile os.FileMode = 0755
	PermissionFile           os.FileMode = 0644

	PermissionDirectoryOwnerOnly os.FileMode = 0700
	PermissionFileOwnerOnly      os.FileMode = 0600

	PermissionMaskDirectoryExecute os.FileMode = 0100
)

Variables

This section is empty.

Functions

func DirExists

func DirExists(dirPath string) bool

DirExists checks if the given directory path exists. It returns true if the directory exists, false otherwise.

func FileExists

func FileExists(filePath string) bool

FileExists checks if the given file path exists and is a regular file. It returns true if the file exists and is regular, false otherwise.

func GetNewLineSeparator

func GetNewLineSeparator() string

func GetenvOrDefault

func GetenvOrDefault(key string, def string) string

GetenvOrDefault behaves like `os.Getenv`, except it returns a specified default value if the key is not present in the environment.

func IsDirEmpty

func IsDirEmpty(directoryPath string, treatMissingAsEmpty ...bool) (bool, error)

IsDirEmpty checks if the given directory is empty. If the directory does not exist, it can either treat it as an error or as an empty directory based on the input flag. By default, it treats a missing directory as an error.

func Rename

func Rename(ctx context.Context, old, new string) error

Rename is like os.Rename in every way. The context is ignored.

func RunningFromPipeline

func RunningFromPipeline() bool

Types

type ExpandableString

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

ExpandableString is a string that has ${foo} style references inside which can be evaluated.

func NewExpandableString

func NewExpandableString(template string) ExpandableString

func (ExpandableString) Empty

func (e ExpandableString) Empty() bool

Empty returns true if the template is empty.

func (ExpandableString) Envsubst

func (e ExpandableString) Envsubst(mapping func(string) string) (string, error)

Envsubst evaluates the template, substituting values as envsubst.Eval would.

func (ExpandableString) MarshalYAML

func (e ExpandableString) MarshalYAML() (interface{}, error)

func (ExpandableString) MustEnvsubst

func (e ExpandableString) MustEnvsubst(mapping func(string) string) string

MustEnvsubst evaluates the template, substituting values as envsubst.Eval would and panics if there is an error (for example, the string is malformed).

func (*ExpandableString) UnmarshalYAML

func (e *ExpandableString) UnmarshalYAML(unmarshal func(interface{}) error) error

type RetryStrategy

type RetryStrategy struct {
	// The maximum number of retries before failing
	MaxRetries uint64
	// The time between each retry attempt
	RetryBackoff time.Duration
}

func NewRetryStrategy

func NewRetryStrategy(maxRetries uint64, retryBackoff time.Duration) *RetryStrategy

Creates a new retry strategy that also reduces the time for when running in test

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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