tasks

package module
v0.0.0-...-3dbd443 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: MIT Imports: 22 Imported by: 1

Documentation

Overview

Copyright (c) 2023 Thomas Ziegler <thomas.zglr@googlemail.com>. All rights reserved.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2023 Thomas Ziegler <thomas.zglr@googlemail.com>. All rights reserved.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2023 Thomas Ziegler <thomas.zglr@googlemail.com>. All rights reserved.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2023 Thomas Ziegler <thomas.zglr@googlemail.com>. All rights reserved.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2023 Thomas Ziegler <thomas.zglr@googlemail.com>. All rights reserved.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2023 Thomas Ziegler <thomas.zglr@googlemail.com>. All rights reserved.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2023 Thomas Ziegler <thomas.zglr@googlemail.com>. All rights reserved.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2023 Thomas Ziegler <thomas.zglr@googlemail.com>. All rights reserved.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2023 Thomas Ziegler <thomas.zglr@googlemail.com>. All rights reserved.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2023 Thomas Ziegler <thomas.zglr@googlemail.com>. All rights reserved.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2023 Thomas Ziegler <thomas.zglr@googlemail.com>. All rights reserved.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Copyright (c) 2023 Thomas Ziegler <thomas.zglr@googlemail.com>. All rights reserved.

Licensed under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

View Source
const GlobalName = "global"

Variables

View Source
var (
	// ShellCmd is the command to execute shell commands
	// It is set to the default value for the current OS
	// If you want to use a different shell, you can change this value
	// before calling any of the tasks
	ShellCmd shellCmd = shellCmd{}
)

Functions

func Execute

func Execute(dCmd string, dCmdArgs []string, command string, callback func(string, error) bool, startInfo func(*os.Process)) (int, int, error)

Execute executes a command and returns the internal exit code, the command exit code and an error the callback function is called for each line of the output the startInfo function is called if the process started and the process id is available

func FindChildPid

func FindChildPid(pid int) ([]int, error)

windows Get-CimInstance Win32_Process | Where-Object { $_.ParentProcessId -eq $ppid } | Select-Object ProcessId

func GetNameOfWatchman

func GetNameOfWatchman(wm *Watchman) (string, bool)

GetNameOfWatchman returns the name of the watchman instance

func GetShellRunner

func GetShellRunner() *shellRunner

func GetShellRunnerForOs

func GetShellRunnerForOs(os string) *shellRunner

func HandleAllMyPid

func HandleAllMyPid(handlePid func(pid int) error) error

func ListWatcherInstances

func ListWatcherInstances() []string

ListWatcherInstances returns a list of all watchman instances as string slice with the uuid string of the watchman instance

func New

func New(target string, arguments map[string]string, any ...interface{}) *targetExecuter

func RequirementCheck

func RequirementCheck(require configure.Require) (bool, string)

func ShutDownProcesses

func ShutDownProcesses(reportFn func(target string, time int, succeed bool))

ShutDownProcesses stops all processes in all watchman instances and reports the result to the reportFn if it is not nil

Types

type CombinedDh

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

CombinedDh is a data handler that combines the functionality of the Placeholder Handler and the Datahandler It uses the Yamc library to store and retrieve data

func NewCombinedDataHandler

func NewCombinedDataHandler() *CombinedDh

func (*CombinedDh) AddData

func (d *CombinedDh) AddData(key string, data map[string]interface{})

func (*CombinedDh) AddJSON

func (d *CombinedDh) AddJSON(key, jsonString string) error

AddJSON adds data by parsing a json string and store them with the given key

func (*CombinedDh) AddYaml

func (d *CombinedDh) AddYaml(key, yamlString string) error

AddJSON adds data by parsing a json string and store them with the given key

func (*CombinedDh) AppendToPH

func (d *CombinedDh) AppendToPH(key, value string) bool

func (*CombinedDh) ClearAll

func (d *CombinedDh) ClearAll()

ClearAll clears all the data

func (*CombinedDh) ExportVarToFile

func (d *CombinedDh) ExportVarToFile(variable string, filename string) error

func (*CombinedDh) GetData

func (d *CombinedDh) GetData(key string) (map[string]interface{}, bool)

func (*CombinedDh) GetDataAsJson

func (d *CombinedDh) GetDataAsJson(key string) (string, bool)

GetDataAsJson returns the data as json string if the key is not present it returns an empty string

func (*CombinedDh) GetDataAsYaml

func (d *CombinedDh) GetDataAsYaml(key string) (string, bool)

GetDataAsYaml returns the data as yaml string if the key is not present it returns an empty string

func (*CombinedDh) GetDataKeys

func (d *CombinedDh) GetDataKeys() []string

func (*CombinedDh) GetJSONPathResult

func (d *CombinedDh) GetJSONPathResult(key, path string) (gjson.Result, bool)

GetJSONPathResult returns the result of a json path query if the key is not present it returns an empty result the returned value is a gjson.Result

func (*CombinedDh) GetPH

func (d *CombinedDh) GetPH(key string) string

func (*CombinedDh) GetPHExists

func (d *CombinedDh) GetPHExists(key string) (string, bool)

GetPHExists returns the value of the placeholder and a boolean if the placeholder exists

func (*CombinedDh) GetPlaceHoldersFnc

func (d *CombinedDh) GetPlaceHoldersFnc(inspectFunc func(phKey string, phValue string))

GetPlaceHoldersFnc iterates over all placeholders and calls the inspectFunc

func (*CombinedDh) GetYamc

func (d *CombinedDh) GetYamc() *yamc.Yamc

func (*CombinedDh) HandlePlaceHolder

func (d *CombinedDh) HandlePlaceHolder(line string) string

HandlePlaceHolder handles the placeholders in the line e.g. ${myKey} will be replaced with the value of myKey if the key does not exist, it will return the original line it will also handle the map placeholders e.g. ${map:myMapKey:myMapPath} it will replace the placeholder with the value of the map if the map does not exist, it will return the original line

func (*CombinedDh) HandlePlaceHolderWithScope

func (d *CombinedDh) HandlePlaceHolderWithScope(line string, scopeVars map[string]string) string

HandlePlaceHolderWithScope handles the placeholders in the line e.g. ${myKey} will be replaced with the value of myKey if the key does not exist, it will return the original line it will also handle the map placeholders e.g. ${map:myMapKey:myMapPath} in addition it will replace the placeholders with the values from the scopeVars

func (*CombinedDh) ImportDataFromYAMLFile

func (d *CombinedDh) ImportDataFromYAMLFile(key string, filename string) error

func (*CombinedDh) SetIfNotExists

func (d *CombinedDh) SetIfNotExists(key, value string)

func (*CombinedDh) SetJSONValueByPath

func (d *CombinedDh) SetJSONValueByPath(key, path, value string) error

SetJSONValueByPath sets a value by a json path using the sjson library

func (*CombinedDh) SetLogger

func (d *CombinedDh) SetLogger(logger mimiclog.Logger)

func (*CombinedDh) SetPH

func (d *CombinedDh) SetPH(key, value string)

type DataMapHandler

type DataMapHandler interface {
	GetJSONPathResult(key, path string) (gjson.Result, bool) // returns the result of a json path query
	GetDataAsJson(key string) (string, bool)                 // returns the data as json string
	GetDataAsYaml(key string) (string, bool)                 // returns the data as yaml string
	AddJSON(key, jsonString string) error                    // adds data by parsing a json string
	SetJSONValueByPath(key, path, value string) error        // sets a value by a json path using
	GetDataKeys() []string                                   // returns all keys
}

DataMapHandler is the interface for the data handlers they are used to store and retrieve data

type DefaultDataHandler

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

DefaultDataHandler is the default implementation of the DataHandler interface It uses the yamc package to store and retrieve data

func NewDefaultDataHandler

func NewDefaultDataHandler() *DefaultDataHandler

func (*DefaultDataHandler) AddData

func (d *DefaultDataHandler) AddData(key string, data interface{})

func (*DefaultDataHandler) AddJSON

func (d *DefaultDataHandler) AddJSON(key, jsonString string) error

func (*DefaultDataHandler) GetData

func (d *DefaultDataHandler) GetData(key string) (interface{}, bool)

func (*DefaultDataHandler) GetDataAsJson

func (d *DefaultDataHandler) GetDataAsJson(key string) (string, bool)

func (*DefaultDataHandler) GetDataAsYaml

func (d *DefaultDataHandler) GetDataAsYaml(key string) (string, bool)

func (*DefaultDataHandler) GetDataKeys

func (d *DefaultDataHandler) GetDataKeys() []string

func (*DefaultDataHandler) GetJSONPathResult

func (d *DefaultDataHandler) GetJSONPathResult(key, path string) (gjson.Result, bool)

func (*DefaultDataHandler) GetYamc

func (d *DefaultDataHandler) GetYamc() *yamc.Yamc

func (*DefaultDataHandler) ImportDataFromYAMLFile

func (d *DefaultDataHandler) ImportDataFromYAMLFile(key string, filename string) error

func (*DefaultDataHandler) SetJSONValueByPath

func (d *DefaultDataHandler) SetJSONValueByPath(key, path, value string) error

type DefaultPhHandler

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

func NewDefaultPhHandler

func NewDefaultPhHandler() *DefaultPhHandler

func (*DefaultPhHandler) AppendToPH

func (d *DefaultPhHandler) AppendToPH(key, value string) bool

func (*DefaultPhHandler) ClearAll

func (d *DefaultPhHandler) ClearAll()

func (*DefaultPhHandler) ExportVarToFile

func (d *DefaultPhHandler) ExportVarToFile(variable string, filename string) error

func (*DefaultPhHandler) GetPH

func (d *DefaultPhHandler) GetPH(key string) string

func (*DefaultPhHandler) GetPHExists

func (d *DefaultPhHandler) GetPHExists(key string) (string, bool)

func (*DefaultPhHandler) GetPlaceHoldersFnc

func (d *DefaultPhHandler) GetPlaceHoldersFnc(inspectFunc func(phKey string, phValue string))

func (*DefaultPhHandler) HandlePlaceHolder

func (d *DefaultPhHandler) HandlePlaceHolder(line string) string

func (*DefaultPhHandler) HandlePlaceHolderWithScope

func (d *DefaultPhHandler) HandlePlaceHolderWithScope(line string, scopeVars map[string]string) string

func (*DefaultPhHandler) SetIfNotExists

func (d *DefaultPhHandler) SetIfNotExists(key, value string)

func (*DefaultPhHandler) SetPH

func (d *DefaultPhHandler) SetPH(key, value string)

type DefaultRequires

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

func NewDefaultRequires

func NewDefaultRequires(variables PlaceHolder, logger mimiclog.Logger) *DefaultRequires

func (*DefaultRequires) CheckReason

func (d *DefaultRequires) CheckReason(checkReason configure.Trigger, output string, e error) (bool, string)

checks reasons that is used for some triggers returns bool and a message what trigger was matched and the reason

func (*DefaultRequires) CheckRequirements

func (d *DefaultRequires) CheckRequirements(require configure.Require) (bool, string)

test all requirements - operation system - variable matches - files exists - files not exists - environment variables returns bool and the message what is checked.

func (*DefaultRequires) StringMatchTest

func (d *DefaultRequires) StringMatchTest(pattern, value string) bool

StringMatchTest test a pattern and a value. in this example: myvar: "=hello" the patter is "=hello" and the value should be "hello" for a match

type MainCmdSetter

type MainCmdSetter interface {
	GetMainCmd(cfg configure.Options) (string, []string)
}

type MsgArgs

type MsgArgs []string

type MsgCommand

type MsgCommand string

MsgCommand is the command to execute

type MsgError

type MsgError struct {
	Err       error
	Target    string
	Reference string
}

type MsgExecOutput

type MsgExecOutput struct {
	Target string
	Output string
}

type MsgInfo

type MsgInfo string

MsgInfo is the info that is just some additional context

type MsgNumber

type MsgNumber int

MsgNumber is some numeric value

type MsgPid

type MsgPid struct {
	Pid    int
	Target string
}

type MsgProcess

type MsgProcess struct {
	Target       string
	StatusChange string
	Comment      string
}

MsgProcess is the process id that is running

type MsgReason

type MsgReason string

MsgReason is the reason that is used to set why somethingis triggered. like stopreason

type MsgStickCursor

type MsgStickCursor bool

type MsgTarget

type MsgTarget struct {
	Target  string
	Context string
	Info    string
}

MsgTarget is the target to execute the command on

type MsgType

type MsgType string

MsgType is the type of the message

type PlaceHolder

type PlaceHolder interface {
	SetPH(key, value string)                                                    // sets a placeholder and its value
	AppendToPH(key, value string) bool                                          // appends a value to a placeholder
	SetIfNotExists(key, value string)                                           // sets a placeholder and its value if it does not exist
	GetPHExists(key string) (string, bool)                                      // returns the value of a placeholder if it exists
	GetPH(key string) string                                                    // returns the value of a placeholder if it exists, otherwise it returns the placeholder itself
	GetPlaceHoldersFnc(inspectFunc func(phKey string, phValue string))          // iterates over all placeholders and calls the inspectFunc for each placeholder
	HandlePlaceHolder(line string) string                                       // replaces all placeholders in a string
	HandlePlaceHolderWithScope(line string, scopeVars map[string]string) string // replaces all placeholders in a string with a scope
	ClearAll()                                                                  // clears all placeholders
	ExportVarToFile(variable string, filename string) error                     // exports a placeholder to a file
}

PlaceHolder is the interface for the placeholder handler they are used to store and retrieve placeholder

type ProcessDef

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

type ProcessLog

type ProcessLog struct {
	Cmd     string
	Args    []string
	Command string
	Pid     int
}

type Requires

type Requires interface {
	CheckRequirements(require configure.Require) (bool, string)
	CheckReason(checkReason configure.Trigger, output string, e error) (bool, string)
}

type RunnerCtrl

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

func (*RunnerCtrl) Cmd

func (r *RunnerCtrl) Cmd(cmd string) error

func (*RunnerCtrl) GetRunner

func (r *RunnerCtrl) GetRunner() *process.Process

func (*RunnerCtrl) GetTask

func (r *RunnerCtrl) GetTask() configure.Task

type TaskDef

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

TaskDef holds information about running and finished tasks

func (*TaskDef) GetProcess

func (ts *TaskDef) GetProcess() *ProcessDef

func (*TaskDef) GetProcessLog

func (ts *TaskDef) GetProcessLog() []ProcessLog

func (*TaskDef) GetProcessPid

func (ts *TaskDef) GetProcessPid() (int, bool)

func (*TaskDef) IsProcessRunning

func (ts *TaskDef) IsProcessRunning() bool

func (*TaskDef) KillProcess

func (ts *TaskDef) KillProcess() error

func (*TaskDef) LogCmd

func (ts *TaskDef) LogCmd(cmd string, args []string, command string)

func (*TaskDef) StartTrackProcess

func (ts *TaskDef) StartTrackProcess(proc *os.Process)

func (*TaskDef) StopProcessIfRunning

func (ts *TaskDef) StopProcessIfRunning() error

StopProcessIfRunning sends an interrupt signal to the process if the process is running if the process is not running, nothing happens. will not reported as error

type TaskListExec

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

func NewStdTaskListExec

func NewStdTaskListExec(config configure.RunConfig, adds ...interface{}) *TaskListExec

func NewTaskListExec

func NewTaskListExec(config configure.RunConfig, adds ...interface{}) *TaskListExec

func (*TaskListExec) GetTask

func (e *TaskListExec) GetTask(target string) *targetExecuter

func (*TaskListExec) GetWatch

func (e *TaskListExec) GetWatch() *Watchman

func (*TaskListExec) RunTarget

func (e *TaskListExec) RunTarget(target string, async bool) int

func (*TaskListExec) RunTargetWithVars

func (e *TaskListExec) RunTargetWithVars(target string, scopeVars map[string]string, async bool) int

func (*TaskListExec) SetHardExistToAllTasks

func (e *TaskListExec) SetHardExistToAllTasks(exitOnErr bool)

func (*TaskListExec) SetLogger

func (e *TaskListExec) SetLogger(logger mimiclog.Logger)

type Watchman

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

the watchman implementation

func GetWatcherInstance

func GetWatcherInstance(uuidString string) *Watchman

GetWatcherInstance returns the watchman instance for a given uuid string or nil if the instance does not exists

func NewGlobalWatchman

func NewGlobalWatchman() *Watchman

NewGlobalWatchman returns the global watchman instance. if the global watchman instance does not exists, it will be created this is a shortcut for GetWatcherInstance(GlobalName) and storeNamedInstance(wm, GlobalName) if the instance does not exists

func NewWatchman

func NewWatchman() *Watchman

NewWatchman returns a new watchman instance and stores it in the global watchman instance list

func (*Watchman) ExpectTaskToStart

func (w *Watchman) ExpectTaskToStart(tickTimer time.Duration, timeoutTickCount int) bool

ExpectTaskToStart waits until some of the tasks are started or the timeout is reached the timeout is defined by the tickTimer multiplied by the timeoutTickCount if we hit the timeout, we return false if we found a running task, we return true

func (*Watchman) GetAllRunningTasks

func (w *Watchman) GetAllRunningTasks() []string

returns the list of all running tasks as string slice by the task name

func (*Watchman) GetTask

func (w *Watchman) GetTask(target string) (TaskDef, bool)

GetTask returns the task info for a given target or false if the task does not exists

func (*Watchman) GetTaskCount

func (w *Watchman) GetTaskCount(target string) int

func (*Watchman) GetTaskDone

func (w *Watchman) GetTaskDone(target string) bool

func (*Watchman) IncTaskCount

func (w *Watchman) IncTaskCount(target string) int

Increases the task count for a given target. If the task does not exists it will be created

func (*Watchman) IncTaskDoneCount

func (w *Watchman) IncTaskDoneCount(target string) (bool, error)

Increases the task done count for a given target. If the task does not exists it will not be created. Instead an error will be returned. there is also no check against the count. So it is possible to increase the done count higher than the count of task runs

func (*Watchman) ListTasks

func (w *Watchman) ListTasks() []string

func (*Watchman) ResetAllTaskInfos

func (w *Watchman) ResetAllTaskInfos()

ResetAllTaskInfos resets all task infos

func (*Watchman) ResetAllTasksIfPossible

func (w *Watchman) ResetAllTasksIfPossible() error

func (*Watchman) SetLogger

func (w *Watchman) SetLogger(logger mimiclog.Logger)

SetLogger sets the logger for the watchman fullfills the mimiclog.Logger interface

func (*Watchman) StopAllTasks

func (w *Watchman) StopAllTasks(reportFn func(target string, time int, succeed bool))

StopAllTasks stops all tasks they are registered in the watchman and reports the result to the reportFn if it is not nil

func (*Watchman) TaskRunning

func (w *Watchman) TaskRunning(target string) bool

TaskRunning checks if a task is already running

func (*Watchman) TryCreate

func (w *Watchman) TryCreate(target string) bool

create a new task if it does not exists. if the handleFn is not nil, it will be called with the result of the check. it resturns true if the task is created or false if the task already exists

func (*Watchman) UntilDone

func (w *Watchman) UntilDone(tickTimer time.Duration, timeOut time.Duration) bool

func (*Watchman) UpdateTask

func (w *Watchman) UpdateTask(target string, task TaskDef) error

Updates the task info for a given target

func (*Watchman) WaitForProcessStart

func (w *Watchman) WaitForProcessStart(target string, tickDuration time.Duration, maxTicks int) (bool, int)

WaitForProcessStart waits until the process is started or the timeout is reached the timeout is defined by the tickDuration multiplied by the maxTicks

func (*Watchman) WaitForStopProcess

func (w *Watchman) WaitForStopProcess(target string, tickDuration time.Duration, maxTicks int) (bool, int)

type WinProcData

type WinProcData struct {
	Pid         int
	ProcName    string
	SessionName string
	SessionId   int
	MemUsage    string
	Status      string
	UserName    string
	CpuTime     string
	WindowTitle string
}

WinProcData is a struct to hold the data of a process on windows

func WinCsvToProcData

func WinCsvToProcData(csv string) ([]WinProcData, error)

parsing the csv output of tasklist comming from windows tasklist command

func WinProcInfo

func WinProcInfo(pid int) (WinProcData, error)

Getting process info on windows is a bit tricky we use the tasklist command to get the info and parse the csv output

Jump to

Keyboard shortcuts

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