Documentation ¶
Overview ¶
Package utils - Utils for cloud testing tool
Index ¶
- func ClearFolder(root string, recreate bool)
- func Contains(a []string, x string) bool
- func CreateFolders(root string)
- func ExecRead(ctx context.Context, dir string, args []string) ([]string, error)
- func FileExists(root string) bool
- func FilterByPattern(source []string, pattern string) ([]string, error)
- func GetAllFiles(dir string) []string
- func MatchRetestPattern(patterns []string, line string) bool
- func NewLogKeeper() *logKeeper
- func NewOSSignalChannel() chan os.Signal
- func NewRandomStr(size int) string
- func OpenFile(root, fileName string) (string, *os.File, error)
- func ParseCommandLine(cmdLine string) []string
- func ParseScript(s string) []string
- func ParseVariable(variable string) (string, string, error)
- func ReadFile(fileName string) ([]string, error)
- func RunCommand(context context.Context, cmd, dir string, logger func(str string), ...) (string, error)
- func SubstituteVariable(variable string, vars, args map[string]string) (string, error)
- func WriteFile(root, fileName, content string)
- type EnvVar
- type ProcWrapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearFolder ¶
ClearFolder - If folder exists it will be removed with all subfolders and if recreate is passed it will be created
func MatchRetestPattern ¶
MatchRetestPattern - check if retest pattern is matched in passed string
func NewLogKeeper ¶
func NewLogKeeper() *logKeeper
NewLogKeeper - creates new instance of logrus log collector
func NewOSSignalChannel ¶
func NewRandomStr ¶
NewRandomStr - generates random string of desired length, size should be multiple of two for best result.
func ParseCommandLine ¶
ParseCommandLine - parses command line with support of "" and escaping.
func ParseScript ¶
ParseScript - parse multi line script and return individual commands.
func ParseVariable ¶
ParseVariable - parses var=value variable format.
func RunCommand ¶
func RunCommand(context context.Context, cmd, dir string, logger func(str string), writer *bufio.Writer, env []string, args map[string]string, returnStdout bool) (string, error)
RunCommand - run shell command and put output into file, command variables are substituted.
func SubstituteVariable ¶
SubstituteVariable - perform a substitution of all ${var} $(arg) in passed string and return substitution results and error
Types ¶
type EnvVar ¶
type EnvVar string
EnvVar provides API for access to env variable
func (EnvVar) StringValue ¶
StringValue returns value of env variable as string
type ProcWrapper ¶
type ProcWrapper struct { Cmd *exec.Cmd Stdout io.ReadCloser Stderr io.ReadCloser // contains filtered or unexported fields }
ProcWrapper - A simple process wrapper
func (*ProcWrapper) ExitCode ¶
func (w *ProcWrapper) ExitCode() int
ExitCode - wait for completion and return exit code