Documentation ¶
Index ¶
Constants ¶
const ( // HOOK_SUCCESS is returned when the hook worked. HOOK_SUCCESS = 0 // HOOK_DOES_NOT_EXIST is returned when the hook cannot be found. HOOK_DOES_NOT_EXIST = -1 // HOOK_STAT_FAILED is returned when the hook exists, but stat // on it fails. HOOK_STAT_FAILED = -2 // HOOK_CANNOT_GET_EXIT_STATUS is returned when after // execution, we fail to get the exit code for the hook. HOOK_CANNOT_GET_EXIT_STATUS = -3 // HOOK_INVALID_NAME is returned if a hook has an invalid name. HOOK_INVALID_NAME = -4 // HOOK_VTROOT_ERROR is returned if VTROOT is not set properly. HOOK_VTROOT_ERROR = -5 // HOOK_GENERIC_ERROR is returned for unknown errors. HOOK_GENERIC_ERROR = -6 )
The hook will return a value between 0 and 255. 0 if it succeeds. So we have these additional values here for more information.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hook ¶
Hook is the input structure for this library.
func NewHookWithEnv ¶
NewHookWithEnv returns a Hook object with the provided name, params and ExtraEnv.
func NewSimpleHook ¶
NewSimpleHook returns a Hook object with just a name.
func (*Hook) Execute ¶
func (hook *Hook) Execute() (result *HookResult)
Execute tries to execute the Hook and returns a HookResult.
func (*Hook) ExecuteAsReadPipe ¶
ExecuteAsReadPipe will execute the hook as in a Unix pipe, reading from the provided reader. It will return: - an io.Reader to read piped data from. - a WaitFunc method to call to wait for the process to exit, that returns stderr and the Wait() error. - an error code and an error if anything fails.
func (*Hook) ExecuteAsWritePipe ¶
ExecuteAsWritePipe will execute the hook as in a Unix pipe, directing output to the provided writer. It will return: - an io.WriteCloser to write data to. - a WaitFunc method to call to wait for the process to exit, that returns stderr and the cmd.Wait() error. - an error code and an error if anything fails.
func (*Hook) ExecuteOptional ¶
ExecuteOptional executes an optional hook, logs if it doesn't exist, and returns a printable error.
type HookResult ¶
type HookResult struct { ExitStatus int // HOOK_SUCCESS if it succeeded Stdout string Stderr string }
HookResult is returned by the Execute method.
func (*HookResult) String ¶
func (hr *HookResult) String() string
String returns a printable version of the HookResult