exec

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrExecEmpty indicates that the user specified an empty "exec"
	// field
	ErrExecEmpty = fmt.Errorf(
		"%w: expected non-empty exec field", gdterrors.ErrParse,
	)
	// ErrExecInvalid indicates that the user specified an invalid "exec" field
	ErrExecInvalid = fmt.Errorf(
		"%w: invalid exec field", gdterrors.ErrParse,
	)
)
View Source
var (
	// ErrUnknownShell returns an ErrParse when an unknown shell is specified
	ErrUnknownShell = fmt.Errorf(
		"%w: unknown shell", errors.ErrParse,
	)
)

Functions

func ExecEmpty

func ExecEmpty(node *yaml.Node) error

ExecEmpty returns an ErrExecEmpty with the line/column of the supplied YAML node.

func ExecInvalidShellParse

func ExecInvalidShellParse(err error) error

ExecInvalidShellParse returns an ErrExecInvalid with the error from shlex.Split

func ExecRuntimeError

func ExecRuntimeError(err error) error

ExecRuntimeError returns a RuntimeError with an error from the Exec() call.

func Plugin

func Plugin() gdttypes.Plugin

Plugin returns the HTTP gdt plugin

func UnknownShell

func UnknownShell(shell string) error

UnknownShell returns a wrapped version of ErrParse that indicates the user specified an unknown shell.

Types

type Defaults

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

Defaults is the known exec plugin defaults collection

func (*Defaults) UnmarshalYAML

func (d *Defaults) UnmarshalYAML(node *yaml.Node) error

type Expect

type Expect struct {
	// ExitCode is the expected exit code for the executed command. The default
	// (0) is the universal successful exit code, so you only need to set this
	// if you expect a non-successful result from executing the command.
	ExitCode int `yaml:"exit_code,omitempty"`
	// Out has things that are expected in the stdout response
	Out *PipeExpect `yaml:"out,omitempty"`
	// Err has things that are expected in the stderr response
	Err *PipeExpect `yaml:"err,omitempty"`
}

Expect contains the assertions about an Exec Spec's actions

func (*Expect) UnmarshalYAML

func (e *Expect) UnmarshalYAML(node *yaml.Node) error

type PipeExpect

type PipeExpect struct {
	// Is contains the exact match (minus whitespace) of the contents of the
	// pipe
	Is *string `yaml:"is,omitempty"`
	// Contains is one or more strings that *all* must be present in the
	// contents of the pipe
	Contains []string `yaml:"contains,omitempty"`
	// ContainsOneOf is one or more strings of which *at least one* must be
	// present in the contents of the pipe
	ContainsOneOf []string `yaml:"contains_one_of,omitempty"`
}

PipeExpect contains assertions about the contents of a pipe

type Spec

type Spec struct {
	gdttypes.Spec
	// Exec is the exact command to execute.
	//
	// You may execute more than one command but must include the `shell` field
	// to indicate that the command should be run in a shell. It is best
	// practice, however, to simply use multiple `exec` specs instead of
	// executing multiple commands in a single shell call.
	Exec string `yaml:"exec"`
	// Shell is the specific shell to use in executing the command. If empty
	// (the default), no shell is used to execute the command and instead the
	// operating system's `exec` family of calls is used.
	Shell string `yaml:"shell,omitempty"`
	// Assert is an object containing the conditions that the Spec will assert.
	Assert *Expect `yaml:"assert,omitempty"`
}

Spec describes a single Spec that executes one or more commands via the operating system's `exec` family of functions.

func (*Spec) Base

func (s *Spec) Base() *gdttypes.Spec

func (*Spec) Eval

func (s *Spec) Eval(ctx context.Context, t *testing.T) *result.Result

Eval performs an action and evaluates the results of that action, returning a Result that informs the Scenario about what failed or succeeded about the Evaluable's conditions.

func (*Spec) SetBase

func (s *Spec) SetBase(b gdttypes.Spec)

func (*Spec) UnmarshalYAML

func (s *Spec) UnmarshalYAML(node *yaml.Node) error

Jump to

Keyboard shortcuts

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