Documentation
¶
Index ¶
- Constants
- func CmdRegister(cmd Cmd) error
- func CmdUnregister(cmd Cmd) error
- func GetNbOfCmds() int
- func LoadModules(dir string) error
- type Cmd
- type CmdFunc
- type CmdRegistry
- type CmdResult
- type Flow
- type Group
- type Host
- type Inventory
- type Job
- func (job *Job) AddTask(task *Task)
- func (job *Job) CheckTasks() error
- func (job *Job) GetTaskByName(name string) (*Task, error)
- func (job *Job) RenderTaskTemplate(task *Task) error
- func (job *Job) Run(tasks string) error
- func (job *Job) RunAllTasks(task *Task) error
- func (job *Job) RunTaskByTask(tasks string) error
- type ModuleRegistry
- type Plugin
- type Task
Constants ¶
const ( // FAILED when a task failed FAILED = iota // SUCCESS when all tasks succedded SUCCESS )
///////// DECLARATION OF ALL TYPES //////////////////////////
Variables ¶
This section is empty.
Functions ¶
func CmdRegister ¶
CmdRegister registers a new command cmd: Command to register
func CmdUnregister ¶
CmdUnregister unregister a command in command registry cmd: command to unregister
func GetNbOfCmds ¶
func GetNbOfCmds() int
GetNbOfCmds returns the number of commands in the registry
func LoadModules ¶
LoadModules loads all modules (plugins) present in the module directory
dir: string specifing the location of modules to load
Types ¶
type Cmd ¶
type Cmd struct { // Name is command name Name string // Func is command function Func CmdFunc // Plugin is the module to which the command belongs to Plugin Plugin }
Cmd is a structure for a command of a given module
func GetCmdByName ¶
GetCmdByName returns a command by its name
type CmdRegistry ¶
CmdRegistry is a registry for commands
This is a map with Key: string composed of module name and command name and Cmd: command structure
func GetCmdRegistry ¶
func GetCmdRegistry() *CmdRegistry
GetCmdRegistry returns the command registry initialized
type CmdResult ¶
type CmdResult struct { // Error is command error Error error // Result is a map containing output of each task Result map[string]interface{} }
CmdResult represents the result of a module's command executed.
type Flow ¶
type Flow struct { Variables map[string]interface{} Jobs []*Job Inventory *Inventory RemoteExecDir string InventoryFile string // IsOnRemote indicates if the flow file is on remote machine // even if it is local IsOnRemote bool Status int Result map[string][]*Job }
Flow represents job flow YAML file containing different sections such as variables, multiple jobs etc.
type Inventory ¶
type Inventory struct { Global map[string]interface{} Hosts map[string]Host Groups map[string]Group }
Inventory describes attributes of a host inventory
type Job ¶
type Job struct { Name string Hosts string Start *Task Tasks []*Task Context map[string]interface{} Status int Result map[string]*CmdResult }
Job describes structure of a job
func (*Job) CheckTasks ¶
CheckTasks checks all tasks to see if the name given for task on failure or on success matches valid task names
func (*Job) GetTaskByName ¶
GetTaskByName returns task by its name in the task list of the job
func (*Job) RenderTaskTemplate ¶
RenderTaskTemplate renders go template in each param with the values in Job Context & Result
func (*Job) Run ¶
Run a job throught all tasks
Firstly, it checks to ensure that all task's names are valid task.fmt_unicode
func (*Job) RunAllTasks ¶
RunAllTasks executes all task functions one by one.
If a task returns error, it will check if task's OnFailure is specified and then go on it. Otherwise, it return task error.
If a task returns success, check and continue with task's OnSuccess if specified or next task in order.
func (*Job) RunTaskByTask ¶
RunTaskByTask executes only tasks in the list specified in command line parameter. It return error if a task fails.
In this function, task's OnSuccess or OnFailure are ignored.
type ModuleRegistry ¶
ModuleRegistry is a registry for modules
func GetModuleRegistry ¶
func GetModuleRegistry() *ModuleRegistry
GetModuleRegistry returns the module registry initialized