hook

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package hook provides standardised way to trigger hooks and provide values at different points in execution

Index

Constants

View Source
const CombinedType = "combined"

CombinedType is the type of the CombinedExecute; designed to link together multiple executers and to provide a simplified single entry point

Variables

This section is empty.

Functions

This section is empty.

Types

type CombinedExecute

type CombinedExecute struct {
	Executers []Executer
}

CombinedExecute is an executer that contains subexecuters that it will forward hook requests to; designed to link together multiple executers and to provide a simplified single entry point

func (*CombinedExecute) ExecuteWithValue

func (e *CombinedExecute) ExecuteWithValue(definition *Definition, value string) (string, error)

ExecuteWithValue takes in a hook definition and a value to pass, it will look at the stored sub executers and decide which executer to use for the hook provided

func (*CombinedExecute) GetType

func (e *CombinedExecute) GetType() string

GetType returns the CombinedExecute type

type Definition

type Definition struct {
	Type    string `json:"type"`
	Timeout int    `json:"timeout"`
	Shell   *Shell `json:"shell"`
	HTTP    *HTTP  `json:"http"`
}

Definition describes a hook for passing data/triggering logic, such as through a shell command

type Executer

type Executer interface {
	ExecuteWithValue(definition *Definition, value string) (string, error)
	GetType() string
}

Executer interface provides methods for executing user logic with a value passed through to it

type HTTP

type HTTP struct {
	Method        string            `json:"method"`
	URL           string            `json:"url"`
	Headers       map[string]string `json:"headers,omitempty"`
	SuccessCodes  []int             `json:"successCodes"`
	ParameterMode string            `json:"parameterMode"`
}

HTTP describes configuration options for an HTTP request hook

type Shell

type Shell struct {
	Command    []string `json:"command"`
	Entrypoint string   `json:"entrypoint"`
}

Shell describes configuration options for a shell command hook

Directories

Path Synopsis
Package http handles interactions over HTTP
Package http handles interactions over HTTP
Package shell handles interactions with the OS shell
Package shell handles interactions with the OS shell

Jump to

Keyboard shortcuts

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