middleware

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2021 License: GPL-2.0, GPL-3.0 Imports: 19 Imported by: 0

README

Middleware

Each middleware implements a function with the following signature

func (middleware CatchMiddleware) Run(
	invocation *models.PipelineInvocation,
	result *models.RunResult,
	next func(*models.PipelineInvocation, *models.RunResult),
	logger *logging.MiddlewareLogger,
	stack *middleware.Stack) {}

Built-in middleware

catch - Error Handler
dir - Directory Navigator
docker - Docker Executor
each - Input Duplicator
timer - Directory Timer Middleware

Writing your own middleware

Documentation

Overview

Each middleware provides an implementation slice, performing side effects and adapting the run based on provided arguments

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LookUpPipelineDefinition

func LookUpPipelineDefinition(definitionsLookup pipeline.PipelineDefinitionsLookup, identifier string, rootFileName string) (*pipeline.PipelineDefinition, bool)

func ParseArguments

func ParseArguments(
	middlewareArguments interface{},
	middlewareIdentifier string,
	run *pipeline.Run,
) bool

func ParseArgumentsIncludingParents

func ParseArgumentsIncludingParents(
	middlewareArguments interface{},
	middlewareIdentifier string,
	run *pipeline.Run,
) bool

Types

type Arguments

type Arguments = map[string]interface{}

type ExecutionContext

type ExecutionContext struct {
	PipelineFiles   []pipeline.File
	Definitions     pipeline.PipelineDefinitionsLookup
	MiddlewareStack []Middleware
	Defaults        pipeline.DefaultSettings
	Hooks           pipeline.HookDefinitions

	Log *logrus.Logger

	ProjectPath  string
	RootFileName string

	SelectableFiles []string

	Runs []*pipeline.Run

	ActivityIndicator logging.ActivityIndicator

	UserPromptImplementation func(
		label string,
		items []string,
		initialSelection int,
		size int,
		input io.ReadCloser,
		output io.WriteCloser,
	) (int, string, error)
	// contains filtered or unexported fields
}

func NewExecutionContext

func NewExecutionContext(options ...ExecutionContextOption) *ExecutionContext

func (*ExecutionContext) Cancel

func (executionContext *ExecutionContext) Cancel() error

func (*ExecutionContext) CancelAll

func (executionContext *ExecutionContext) CancelAll() error

func (*ExecutionContext) Execute

func (executionContext *ExecutionContext) Execute(pipelineIdentifier string, writer io.Writer)

func (*ExecutionContext) FullRun

func (executionContext *ExecutionContext) FullRun(options ...FullRunOption) *pipeline.Run

func (*ExecutionContext) PipelineFileAtPath

func (executionContext *ExecutionContext) PipelineFileAtPath(path string) (*pipeline.File, error)

func (*ExecutionContext) SetUpPipelines

func (executionContext *ExecutionContext) SetUpPipelines(args []string) error

type ExecutionContextOption

type ExecutionContextOption func(*ExecutionContext)

func WithActivityIndicator

func WithActivityIndicator(activityIndicator logging.ActivityIndicator) ExecutionContextOption

func WithExecutionFunction

func WithExecutionFunction(executionFunction func(run *pipeline.Run)) ExecutionContextOption

func WithLogger

func WithLogger(logger *logrus.Logger) ExecutionContextOption

func WithMiddlewareStack

func WithMiddlewareStack(stack []Middleware) ExecutionContextOption

func WithParser

func WithParser(parser *parser.Parser) ExecutionContextOption

func WithProjectPath

func WithProjectPath(projectPath string) ExecutionContextOption

func WithUserPromptImplementation

func WithUserPromptImplementation(implementation func(
	label string,
	items []string,
	initialSelection int,
	size int,
	input io.ReadCloser,
	output io.WriteCloser,
) (int, string, error)) ExecutionContextOption

type FullRunOption

type FullRunOption func(*FullRunOptions)

func WithArguments

func WithArguments(arguments map[string]interface{}) FullRunOption

func WithIdentifier

func WithIdentifier(identifier *string) FullRunOption

func WithLogWriter

func WithLogWriter(logWriter io.WriteCloser) FullRunOption

func WithParentRun

func WithParentRun(parentRun *pipeline.Run) FullRunOption

func WithSetupFunc

func WithSetupFunc(preCallback func(*pipeline.Run)) FullRunOption

func WithTearDownFunc

func WithTearDownFunc(postCallback func(*pipeline.Run)) FullRunOption

type FullRunOptions

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

type Middleware

type Middleware interface {
	String() string
	Apply(
		run *pipeline.Run,
		next func(*pipeline.Run),
		executionContext *ExecutionContext,
	)
}

type PipelineReference

type PipelineReference = map[*string]Arguments

Directories

Path Synopsis
The `catch` middleware enables graceful handling of stderr output
The `catch` middleware enables graceful handling of stderr output
The `catchEach` middleware enables graceful handling of stderr output based on regex patterns
The `catchEach` middleware enables graceful handling of stderr output based on regex patterns
The `dir` middleware allows for changing the current working directory
The `dir` middleware allows for changing the current working directory
The `docker` middleware enables execution within a Docker (Compose) container
The `docker` middleware enables execution within a Docker (Compose) container
The `each` middleware copies some input into several child pipes running simultaneously
The `each` middleware copies some input into several child pipes running simultaneously
The `env` middleware manipulates environment variables
The `env` middleware manipulates environment variables
The `inherit` middleware passes arguments from a parent to its children
The `inherit` middleware passes arguments from a parent to its children
The `input` middleware overwrites a pipe's input directly
The `input` middleware overwrites a pipe's input directly
The `interpolate` middleware substitutes arguments or inputs into other arguments
The `interpolate` middleware substitutes arguments or inputs into other arguments
The `output` middleware overwrites a pipe's output directly
The `output` middleware overwrites a pipe's output directly
The `pipe` middleware executes several commands in sequence
The `pipe` middleware executes several commands in sequence
The `select` middleware shows selection prompts to the user
The `select` middleware shows selection prompts to the user
The `shell` middleware executes commands in a shell
The `shell` middleware executes commands in a shell
The `ssh` middleware enables remote command execution via SSH
The `ssh` middleware enables remote command execution via SSH
Defines a list of middleware items to be executed when a pipeline is run
Defines a list of middleware items to be executed when a pipeline is run
The `sync` middleware defers execution until a condition is fulfilled
The `sync` middleware defers execution until a condition is fulfilled
The `timer` middleware records execution time
The `timer` middleware records execution time
The `when` middleware enables conditional execution
The `when` middleware enables conditional execution
The `with` middleware extracts and processes input patterns
The `with` middleware extracts and processes input patterns

Jump to

Keyboard shortcuts

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