shell

package
v0.37.1 Latest Latest
Warning

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

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

README

args - Shell Arguments Appender Middleware

The args middleware appends the values provided under the args key to a shell command about to be executed. This is mostly for convenience and clarity - arguments can also be provided to the command string directly, although this often results in long execution strings that are harder to test and annotate with meaningful comments.

Note the difference between shell arguments (passed to the shell command) and pipe arguments (everything provided in the pipe invocation yaml, including the shell arguments under the args key).

Arguments

The args middleware expects an array of values, each in one of the following formats (mixing formats is fine).

Formats
Plain string
- some_pipeline:
    args:
      - string_argument
Long form options

For convenience, options of the common form --flag and --key=string_value can be provided as

- some_pipeline:
    args:
      - flag: true
      - unused_flag: false
      - key: string_value

This form is applied whenever the key does not start with a - and is not a single letter.

Short form options

If the key is a single letter, it will instead be appended to the shell command as -a (for boolean true value) or -cstring_value (for string value) without a space between key and value.

- some_pipeline:
    args:
      - a: true
      - b: false
      - c: string_value
Explicit form

Keys that start with a - will be appended as is, with the value concatenated.

- some_pipeline:
    args:
      - -a: string_value

results in -astring_value being appended.

This form can be used to enforce some custom formats:

- some_pipeline:
    args:
      - "-a ": string_value
      - "-b=": string_value
      - "--c": string_value
      - "--d ": string_value

results in -a string_value -b=string_value --string_value --d string_value being appended to the shell command.

Documentation

Overview

Package shell provides a middleware to execute commands in a shell

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Middleware added in v0.32.2

type Middleware struct {
	ExecutorCreator func() commandExecutor
	// contains filtered or unexported fields
}

Middleware is a shell command runner

func NewMiddleware added in v0.32.2

func NewMiddleware() Middleware

NewMiddleware creates a new middleware instance

func NewMiddlewareWithExecutorCreator added in v0.32.2

func NewMiddlewareWithExecutorCreator(executorCreator func() commandExecutor) Middleware

NewMiddlewareWithExecutorCreator creates a new middleware instance with the specified executor creation function

func (Middleware) Apply added in v0.32.2

func (shellMiddleware Middleware) Apply(
	run *pipeline.Run,
	next func(pipelineRun *pipeline.Run),
	_ *middleware.ExecutionContext,
)

Apply is where the middleware's logic resides

It adapts the run based on its slice of the run's arguments. It may also trigger side effects such as executing shell commands or full runs of other pipelines. When done, this function should call next in order to continue unwinding the stack.

func (Middleware) String added in v0.32.2

func (shellMiddleware Middleware) String() string

String is a human-readable description

Jump to

Keyboard shortcuts

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