checks

package
v0.0.0-...-6dace74 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRequiredArg

func IsRequiredArg(err error) bool

IsRequiredArg returns a boolean indicating if the given err is a RequiredArgError

Types

type ArgFunc

type ArgFunc func(args Args) (Checker, error)

ArgFunc is a function which takes the raw yaml test args and converts them into a Checker

type Args

type Args map[string]interface{}

Args is a convenience type to express the "args" key in the test yaml

type Checker

type Checker interface {
	Check() error
}

Checker is any struct that performs a system check

func CompileGccFromArgs

func CompileGccFromArgs(args Args) (Checker, error)

CompileGccFromArgs will populate the CompileGcc with the args given in the tests YAML config

func CompileVisualStudioFromArgs

func CompileVisualStudioFromArgs(args Args) (Checker, error)

CompileVisualStudioFromArgs will populate the CompileVisualStudio with the args given in the tests YAML config

func FileCheckerFromArgs

func FileCheckerFromArgs(args Args) (Checker, error)

FromArgs will populate the FileChecker with the args given in the tests YAML config

func GemInstalledFromArgs

func GemInstalledFromArgs(args Args) (Checker, error)

FromArgs will populate the GemInstalled struct with the args given in the tests YAML config

func LoadCheck

func LoadCheck(name string, args Args) (Checker, error)

LoadCheck will return the appropriate Checker based on the test type name. As documented on the various checkers

func PipInstalledFromArgs

func PipInstalledFromArgs(args Args) (Checker, error)

FromArgs will populate the PipInstalled struct with the args given in the tests YAML config

func RegistryKeyCheckerFromArgs

func RegistryKeyCheckerFromArgs(args Args) (Checker, error)

FromArgs implements Argable for RegistryKeyChecker

func RunScriptFromArgs

func RunScriptFromArgs(args Args) (Checker, error)

RunScriptFromArgs will populate the RunScript with the args given in the tests YAML config

type CompileGcc

type CompileGcc struct {
	Source        string
	Compiler      string
	Cflags        string
	CflagsCommand string `mapstructure:"cflags_command"`
	Run           bool
}

CompileGcc runs gcc compile.

Type:

  • compile-gcc

Support Platforms:

  • Mac
  • Linux
  • Windows

Arguments:

source (required): The source code to compile.
compiler: path to the compiler. Default is 'gcc' from the $PATH
cflags: compiles flags, string, e.g "-lss -lsasl2"
cflags_command: command to get clags, e.g. "net-snmp-config --agent-libs"
run: If true try running the compiled binary

func (CompileGcc) Check

func (cg CompileGcc) Check() error

Check Runs a gcc command and checks the return code

type CompileVisualStudio

type CompileVisualStudio struct {
	Source    string
	Cflags    string
	Version   float64
	Extension string
	Compiler  string
	Run       bool
}

CompileVisualStudio runs VisualStudio compile.

Type:

  • compile-visual-studio

Support Platforms:

  • Windows

Arguments:

  source (required): The source code to compile.
  cflags: A string that will be parsed using shlex and passed as arguments to cl.exe
  version: Visual studio version to use. Default is the latest version installed on the system
  extension: The file extension to use for the generated temporary file. Default is "cpp"
  run: If true try running the compiled binary
  compiler: A string path to the compiler to use. This is a template that gets
	           one variable: '{{ .VisualStudioPath }}' which is the path to the
            Visual Studio installation we are using, ending with the filepath separator
            '\'. For example for VS2015 it would be:

	           C:\Program Files (x86)\Microsoft Visual Studio 14.0\

	           This allows you to specify compilers other than VC\bin\cl.exe to use.
	           For example if you wanted to compile C#. You can pass a hardcoded string here
	           without the template variable if you wish to specify a full path and
	           bypass our VisualStudio installation detection logic.

	           This defaults to "{{ .VisualStudioPath }}VC\\bin\\cl.exe"

Notes:

For the version argument you can either specify the year (2015) or the actual
version number as recognized by Visual Studio registry entries (14.0) and
this check will do the math to figure out what you want.

func (CompileVisualStudio) Check

func (cvs CompileVisualStudio) Check() error

Check compiles, and optionally runs, code using VisualStudio

type FileChecker

type FileChecker struct {
	Exists bool
	Name   string
}

FileChecker checks if a file exists or does not

Type:

  • file-exists
  • file-does-not-exist

Supported Platforms:

  • MacOS
  • Linux
  • Windows

Arguments:

  name (required): A string value that points to a path on the filesystem.
  exists: An optional boolean indicating whether the file should exist or not.
			 For file-does-not-exist type tests this is always set to false, for
			 the normal file-exists type tests this value defaults to true, the
			 file should exist, but can be set to false if desired.

Notes:

For Unix systems no `~` expansion is done. So ~/.bashrc is not a valid path,
or at least will not do what you think it will. Additionally, when checking
paths on Windows provide windows style paths (i.e. C:\My\File\Path.txt).

func (FileChecker) Check

func (fc FileChecker) Check() error

Check if a file exists or does not

type GemInstalled

type GemInstalled struct {
	Name string
}

GemInstalled checks if ruby gem is installed on the system

Type:

  • gem-installed

Support Platforms:

  • Linux
  • Windows

Argument:

name (required): A string value that represents the gem name

func (GemInstalled) Check

func (gi GemInstalled) Check() error

Check if a deb package is installed on the system

type PipInstalled

type PipInstalled struct {
	Module       string
	Version      string
	Relationship string
	Statement    string
}

PipInstalled checks if python module is installed on the system And verifies its version.

Type:

  • python-module-version

Supported Platforms:

  • Linux
  • Windows

Argument:

module (required): A string value that represents the python module
version: An optional version number to check
         Leave version blank to just verify module is present
statement: Optional python statement, the result will be passed to print()
           Defaults to module.__version__
relationship: Optional comparison operator for the version provided. Valid
              values are lt, lte, gt, gte, eq. Defaults to gte (greater than or equal to)

func (PipInstalled) Check

func (pmv PipInstalled) Check() error

Check if a python module is installed on the system and verify version if the Version string is set

type RegistryKeyChecker

type RegistryKeyChecker struct {
	Root      string
	Path      string
	Key       string
	ValueType string `mapstructure:"value_type"`
	Value     interface{}
}

RegistryKeyChecker verifies the value of a given registry key is correct or exists.

func (RegistryKeyChecker) Check

func (rkc RegistryKeyChecker) Check() error

Check implements Checker for RegistryKeyChecker

type RequiredArgError

type RequiredArgError struct {
	RequiredArg  string
	ProvidedArgs Args
}

RequiredArgError is an error which indicates a required arg was not given

func (RequiredArgError) Error

func (rae RequiredArgError) Error() string

type RunScript

type RunScript struct {
	Source      string
	Output      string
	Interpreter string
}

RunScript runs a bash script and optionally checks output.

Type:

  • run-bash-script

Support Platforms:

  • Mac
  • Linux
  • Windows

Arguments:

source (required): The source code of the script.
output: string to which the output of the script will be compared to determine a successful run. If omitted, only checks that the script exits with returncode 0.
interpreter: path to bash. Default is '/bin/bash'.

Notes:

func (RunScript) Check

func (rs RunScript) Check() error

Check Runs a script and checks the return code or output

Jump to

Keyboard shortcuts

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