actions

package
v0.0.0-...-d2d06f5 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2018 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action interface {
	Execute(context.Context, results.Results) (results.Result, error)
}

Action allows execution

func NewHTTPFromMap

func NewHTTPFromMap(m map[string]interface{}) (Action, error)

NewHTTPFromMap initializes an http action based on generic map

func NewSubprocessFromMap

func NewSubprocessFromMap(m map[string]interface{}) (Action, error)

NewSubprocessFromMap parses generic map into subprocess action

type DummyAction

type DummyAction struct {
	ReturnResult results.Result
}

DummyAction doesn't do anything!

func (DummyAction) Execute

Execute a noop action

type HTTP

type HTTP struct {
	URL       string `mapstructure:"url"`
	Method    string
	Headers   map[string]string
	Overrides []results.Override
	Body      string
	Type      string
}

HTTP action has all data necessary to make a request

func (HTTP) Execute

func (h HTTP) Execute(ctx context.Context, rs results.Results) (results.Result, error)

Execute makes the http request

type HTTPResult

type HTTPResult struct {
	*http.Response
	// contains filtered or unexported fields
}

HTTPResult contains request result and metadata

func (HTTPResult) Error

func (h HTTPResult) Error() error

Error gets the error associated with this result

func (HTTPResult) ValueOfProperty

func (h HTTPResult) ValueOfProperty(property string) (results.Value, error)

ValueOfProperty gets value associated with an identifier

type Registry

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

Registry maps action identifiers to parser functions

func NewRegistry

func NewRegistry() (Registry, error)

NewRegistry initializes loadable actions

func (Registry) Load

func (r Registry) Load(am map[string]interface{}) (Action, error)

Load an action from a generic map

type StubResult

type StubResult struct{}

StubResult is a configurable result for testing

func (StubResult) Error

func (sr StubResult) Error() error

Error returns a stub result error

func (StubResult) ValueOfProperty

func (sr StubResult) ValueOfProperty(property string) (results.Value, error)

ValueOfProperty returns a value and an error for testing

type Subprocess

type Subprocess struct {
	CommandName string `mapstructure:"command_name"`
	Args        []string
	Overrides   []results.Override
	Type        string
}

Subprocess can execute a shell command

func (Subprocess) Execute

func (s Subprocess) Execute(ctx context.Context, rs results.Results) (results.Result, error)

Execute s a shell command in a subprocess

type SubprocessResult

type SubprocessResult struct {
	Output     []byte
	Returncode int
	// contains filtered or unexported fields
}

SubprocessResult from suprocess execution

func (SubprocessResult) Error

func (s SubprocessResult) Error() error

Error unpacks error from the result

func (SubprocessResult) ValueOfProperty

func (s SubprocessResult) ValueOfProperty(property string) (results.Value, error)

ValueOfProperty retrieves a result value based on a property of the result

Jump to

Keyboard shortcuts

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