check

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2016 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package check implements a set of primitive checks that are used to validate inspector rules

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPackageReadyToContinue

func IsPackageReadyToContinue(m PackageManager, q PackageQuery) (bool, error)

Types

type Check

type Check interface {
	Check() (bool, error)
}

A Check implements a workflow that validates a condition. If an error occurs while running the check, it returns false and the error. If the check is able to successfully determine the condition, it returns true if satisfied, or false otherwise.

type ClosableCheck

type ClosableCheck interface {
	Check
	Close() error
}

A ClosableCheck implements a long-running check workflow that requires closing

type Distro

type Distro string

Distro is a Linux distribution that the inspector supports

const (
	Ubuntu      Distro = "ubuntu"
	RHEL        Distro = "rhel"
	CentOS      Distro = "centos"
	Darwin      Distro = "darwin"
	Unsupported Distro = ""
)

func DetectDistro

func DetectDistro() (Distro, error)

DetectDistro uses the /etc/os-release file to get distro information.

type ExecutableInPathCheck

type ExecutableInPathCheck struct {
	Name string
}

ExecutableInPathCheck checks whether the binary is on the executable path

func (ExecutableInPathCheck) Check

func (c ExecutableInPathCheck) Check() (bool, error)

Check returns true if the executable is in the path

type FileContentCheck

type FileContentCheck struct {
	File         string
	SearchString string
}

FileContentCheck runs a search against the contents of the specified file. The SearchString is a regular expression that is in accordance with the RE2 syntax defined by the Go regexp package.

func (FileContentCheck) Check

func (c FileContentCheck) Check() (bool, error)

Check returns true if file contents match the regular expression. Otherwise, returns false. If an error occurrs, returns false and the error.

type PackageAvailableCheck

type PackageAvailableCheck struct {
	PackageQuery   PackageQuery
	PackageManager PackageManager
}

PackageAvailableCheck verifies that a given package is available for download using the operating system's package manager.

func (PackageAvailableCheck) Check

func (c PackageAvailableCheck) Check() (bool, error)

Check returns true if the package is available. Otherwise returns false, or an error if the check is unable to determine the condition.

type PackageManager

type PackageManager interface {
	IsAvailable(PackageQuery) (bool, error)
	IsInstalled(PackageQuery) (bool, error)
	Enforced() bool
}

PackageManager runs queries against the underlying operating system's package manager

func NewPackageManager

func NewPackageManager(distro Distro, enforcePackages bool) (PackageManager, error)

NewPackageManager returns a package manager for the given distribution

type PackageQuery

type PackageQuery struct {
	Name    string
	Version string
}

func (PackageQuery) String

func (p PackageQuery) String() string

type Python2Check

type Python2Check struct {
	SupportedVersions []string
}

Python2Check returns true if python 2 is installed on the node and the version prefix-matches one of the supported versions

func (Python2Check) Check

func (c Python2Check) Check() (bool, error)

type TCPPortClientCheck

type TCPPortClientCheck struct {
	// IPAddress is the IP of the remote node
	IPAddress string
	// PortNumber is the target service port
	PortNumber int
	// Timeout is the maximum amount of time the check will
	// wait when connecting to the server before bailing out
	Timeout time.Duration
}

TCPPortClientCheck verifies that a given port on a remote node is accessible through the network

func (*TCPPortClientCheck) Check

func (c *TCPPortClientCheck) Check() (bool, error)

Check returns true if the TCP connection is established and the server returns the expected response. Otherwise, returns false and an error message

type TCPPortServerCheck

type TCPPortServerCheck struct {
	PortNumber int
	// contains filtered or unexported fields
}

TCPPortServerCheck ensures that the given port is free, and stands up a TCP server that can be used to check TCP connectivity to the host using TCPPortClientCheck

func (*TCPPortServerCheck) Check

func (c *TCPPortServerCheck) Check() (bool, error)

Check returns true if the port is available for the server. Otherwise returns false and an error message

func (*TCPPortServerCheck) Close

func (c *TCPPortServerCheck) Close() error

Close the TCP server

Jump to

Keyboard shortcuts

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