util

package
v0.0.0-...-f761aa5 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyDataDir = errors.New("empty data directory")

ErrEmptyDataDir error to indicate the data directory is empty

Functions

func CheckIfDirEmpty

func CheckIfDirEmpty(dirname string) (rerr error)

CheckIfDirEmpty checks if a directory is empty, returning an ErrEmptyDataDir error if it is

func CheckRequiredSettings

func CheckRequiredSettings(requiredArgs []string) error

CheckRequiredSettings checks for required min values / flags / environment variables

func CopyFileContents

func CopyFileContents(dst, src string) (rerr error)

CopyFileContents copies the contents of the file named src to the file named by dst. The file will be created if it does not already exist. If the destination file exists, all it's contents will be replaced by the contents of the source file.

func CreateMSWorkingDirectory

func CreateMSWorkingDirectory(uid string, scratchDir string) (*os.File, error)

CreateMSWorkingDirectory takes a given prefix and returns a metric sample working directory

func CreateMetricSample

func CreateMetricSample(exportDirectory os.File, uid string, cleanUp bool, scratchDir string) (*os.File, error)

CreateMetricSample creates a metric sample from a given directory removing the source directory if cleanup is true

func IsValidURL

func IsValidURL(toTest string) bool

IsValidURL returns true if string is a valid URL

func MatchOneFile

func MatchOneFile(directory string, pattern string) (fileName string, err error)

MatchOneFile returns the name of one file based on a given directory and pattern returning an error if more or less than one match is found. The syntax of patterns is the same as in filepath.Glob & Match.

func SafeClose

func SafeClose(closer func() error, err *error)

SafeClose will close the given closer function, setting the err ONLY if it is currently nil. This allows for cleaner handling of always-closing, but retaining the original error (ie from a previous Write).

func SetupLogger

func SetupLogger() (err error)

SetupLogger sets configuration for the default logger

func TestHTTPConnection

func TestHTTPConnection(testClient rest.HTTPClient,
	URL, method, bearerToken string, retries uint, verbose bool) (successful bool, body *[]byte, err error)

TestHTTPConnection takes a given client / URL(string) / bearerToken(string)/ retries count (int) and returns true if response code is 2xx.

func ValidateScratchDir

func ValidateScratchDir(scratchDir string) error

ValidateScratchDir validates whether or not the scratch directory exists or not

Types

This section is empty.

Jump to

Keyboard shortcuts

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