shell

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: 12 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

The `shell` middleware executes commands in a shell

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommandExecutor

type CommandExecutor interface {
	Init(name string, arg ...string)
	Kill() error
	CmdStdin() io.WriteCloser
	CmdStdout() io.Reader
	CmdStderr() io.Reader
	Start() error
	String() string
	Wait() error
}

type DefaultCommandExecutor

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

func NewDefaultCommandExecutor

func NewDefaultCommandExecutor() *DefaultCommandExecutor

func (*DefaultCommandExecutor) CmdStderr

func (executor *DefaultCommandExecutor) CmdStderr() io.Reader

func (*DefaultCommandExecutor) CmdStdin

func (executor *DefaultCommandExecutor) CmdStdin() io.WriteCloser

func (*DefaultCommandExecutor) CmdStdout

func (executor *DefaultCommandExecutor) CmdStdout() io.Reader

func (*DefaultCommandExecutor) Init

func (executor *DefaultCommandExecutor) Init(name string, arg ...string)

func (*DefaultCommandExecutor) Kill

func (executor *DefaultCommandExecutor) Kill() error

func (*DefaultCommandExecutor) Start

func (executor *DefaultCommandExecutor) Start() error

func (*DefaultCommandExecutor) String

func (executor *DefaultCommandExecutor) String() string

func (*DefaultCommandExecutor) Wait

func (executor *DefaultCommandExecutor) Wait() error

type ShellMiddleware

type ShellMiddleware struct {
	ExecutorCreator func() CommandExecutor
	// contains filtered or unexported fields
}

Shell Command Runner

func NewShellMiddleware

func NewShellMiddleware() ShellMiddleware

func NewShellMiddlewareWithExecutorCreator

func NewShellMiddlewareWithExecutorCreator(executorCreator func() CommandExecutor) ShellMiddleware

func (ShellMiddleware) Apply

func (shellMiddleware ShellMiddleware) Apply(
	run *pipeline.Run,
	next func(pipelineRun *pipeline.Run),
	executionContext *middleware.ExecutionContext,
)

func (ShellMiddleware) String

func (shellMiddleware ShellMiddleware) String() string

type ShellMiddlewareArguments

type ShellMiddlewareArguments struct {
	Args        []interface{}
	Dir         *string
	Exec        string
	Indefinite  bool
	Interactive bool
	Login       bool
	Run         *string
	Quote       string
}

func NewShellMiddlewareArguments

func NewShellMiddlewareArguments() ShellMiddlewareArguments

Jump to

Keyboard shortcuts

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