middleware

package
v0.32.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

Package middleware slices the implementation into middlewares, each 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
Package catch provides a middleware for graceful handling of stderr output
Package catch provides a middleware for graceful handling of stderr output
Package catcheach provides a middleware for graceful handling of stderr output based on regex patterns
Package catcheach provides a middleware for graceful handling of stderr output based on regex patterns
Package dir provides a middleware for changing the current working directory
Package dir provides a middleware for changing the current working directory
Package docker provides a middleware for execution within a Docker (Compose) container
Package docker provides a middleware for execution within a Docker (Compose) container
Package each provides a middleware that copies some input into several child pipes running simultaneously
Package each provides a middleware that copies some input into several child pipes running simultaneously
Package env provides a middleware handling environment variables
Package env provides a middleware handling environment variables
Package inherit provides a middleware that passes arguments from a parent to its children
Package inherit provides a middleware that passes arguments from a parent to its children
Package input provides a middleware to overwrite a pipe's input directly
Package input provides a middleware to overwrite a pipe's input directly
Package interpolate provides a middleware to substitute arguments or inputs into other arguments
Package interpolate provides a middleware to substitute arguments or inputs into other arguments
Package output provides a middleware to overwrite a pipe's output directly
Package output provides a middleware to overwrite a pipe's output directly
Package pipe provides a middleware to execute several commands in sequence
Package pipe provides a middleware to execute several commands in sequence
Package select provides a middleware that shows a selection prompt to the user
Package select provides a middleware that shows a selection prompt to the user
Package shell provides a middleware to execute commands in a shell
Package shell provides a middleware to execute commands in a shell
Package ssh provides a middleware enabling remote command execution via SSH
Package ssh provides a middleware enabling remote command execution via SSH
Package stack defines a list of middleware items to be executed when a pipeline is run
Package stack defines a list of middleware items to be executed when a pipeline is run
Package sync provides a middleware to defer execution until a condition is fulfilled
Package sync provides a middleware to defer execution until a condition is fulfilled
Package timer provides a middleware that records execution time
Package timer provides a middleware that records execution time
Package when provides a middleware that enables conditional execution
Package when provides a middleware that enables conditional execution
Package with provides a middleware that extracts and processes input patterns
Package with provides a middleware that extracts and processes input patterns

Jump to

Keyboard shortcuts

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