Documentation
¶
Index ¶
- Variables
- func ExecEmpty(node *yaml.Node) error
- func ExecInvalidShellParse(err error, node *yaml.Node) error
- func ExecRuntimeError(err error) error
- func OverrideDefaultTimeout(d string)
- func Plugin() api.Plugin
- func UnknownShell(shell string) error
- type Action
- type Defaults
- type Expect
- type On
- type PipeExpect
- type Spec
- type VarEntry
- type Variables
Constants ¶
This section is empty.
Variables ¶
var ( // ErrExecEmpty indicates that the user specified an empty "exec" // field ErrExecEmpty = fmt.Errorf( "%w: expected non-empty exec field", api.ErrParse, ) // ErrExecInvalid indicates that the user specified an invalid "exec" field ErrExecInvalid = fmt.Errorf( "%w: invalid exec field", api.ErrParse, ) )
var (
DefaultTimeout = "10s"
)
var ( // ErrUnknownShell returns an ErrParse when an unknown shell is specified ErrUnknownShell = fmt.Errorf( "%w: unknown shell", api.ErrParse, ) )
var (
// this is just for testing purposes...
PluginRef = &plugin{}
)
Functions ¶
func ExecInvalidShellParse ¶
ExecInvalidShellParse returns an ErrExecInvalid with the error from shlex.Split
func ExecRuntimeError ¶
ExecRuntimeError returns a RuntimeError with an error from the Exec() call.
func OverrideDefaultTimeout ¶ added in v1.7.1
func OverrideDefaultTimeout(d string)
OverrideDefaultTimeout is only used in testing...
func UnknownShell ¶
UnknownShell returns a wrapped version of ErrParse that indicates the user specified an unknown shell.
Types ¶
type Action ¶ added in v1.2.0
type Action struct {
// 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"`
// VarStdout is a shortcut for Var:{VARIABLE_NAME}:from:stdout
VarStdout string `yaml:"var-stdout,omitempty"`
// VarStderr is a shortcut for Var:{VARIABLE_NAME}:from:stderr
VarStderr string `yaml:"var-stderr,omitempty"`
// VarRC is a shortcut for Var:{VARIABLE_NAME}:from:returncode
VarRC string `yaml:"var-rc,omitempty"`
}
Action describes a single execution of one or more commands via the operating system's `exec` family of functions.
func (*Action) Do ¶ added in v1.2.0
func (a *Action) Do( ctx context.Context, outbuf *bytes.Buffer, errbuf *bytes.Buffer, exitcode *int, ) error
Do performs a single command or shell execution returning the corresponding exit code and any runtime error. The `outbuf` and `errbuf` buffers will be filled with the contents of the command's stdout and stderr pipes respectively.
type Defaults ¶
type Defaults struct {
// contains filtered or unexported fields
}
Defaults is the known exec plugin defaults collection
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
type On ¶ added in v1.2.0
type On struct {
// Fail contains one or more actions to take if any of a Spec's assertions
// fail.
//
// For example, if you wanted to grep a log file in the event that no
// connectivity on a particular IP:PORT combination could be made you might
// do this:
//
// “`yaml
// tests:
// - exec: nc -z $HOST $PORT
// on:
// fail:
// exec: grep ERROR /var/log/myapp.log
// “`
//
// The `grep ERROR /var/log/myapp.log` command will only be executed if
// there is no connectivity to $HOST:$PORT and the results of that grep
// will be directed to the test's output. You can use the `gdt.WithDebug()`
// function to configure additional `io.Writer`s to direct this output to.
Fail *Action `yaml:"fail,omitempty"`
}
On describes actions that can be taken upon certain conditions.
type PipeExpect ¶
type PipeExpect struct {
// ContainsAll is one or more strings that *all* must be present in the
// contents of the pipe
ContainsAll *api.FlexStrings `yaml:"contains,omitempty"`
// ContainsNone is one or more strings, *none of which* should be present in
// the contents of the pipe
ContainsNone *api.FlexStrings `yaml:"contains-none-of,omitempty"`
// ContainsOneOf is one or more strings of which *at least one* must be
// present in the contents of the pipe
ContainsAny *api.FlexStrings `yaml:"contains-one-of,omitempty"`
}
PipeExpect contains assertions about the contents of a pipe
func (*PipeExpect) UnmarshalYAML ¶ added in v1.3.0
func (e *PipeExpect) UnmarshalYAML(node *yaml.Node) error
type Spec ¶
type Spec struct {
api.Spec
Action
// Assert is an object containing the conditions that the Spec will assert.
Assert *Expect `yaml:"assert,omitempty"`
// On is an object containing actions to take upon certain conditions.
On *On `yaml:"on,omitempty"`
// Var allows the test author to save arbitrary data to the test scenario,
// facilitating the passing of variables between test specs potentially
// provided by different gdt Plugins.
Var Variables `yaml:"var,omitempty"`
}
Spec describes a single Spec that executes one or more commands via the operating system's `exec` family of functions.
type VarEntry ¶ added in v1.9.8
type VarEntry struct {
// From is a string that indicates where the value of the variable will be
// sourced from. `stdout`, `stderr` and `returncode` indicate to source the
// value of the variable from the output buffer for stdout, stderr or the
// returncode value. All other strings indicate the value of the variable
// should be sourced from an envvar of the same name.
From string `yaml:"from"`
}