check

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2017 License: Apache-2.0 Imports: 15 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

This section is empty.

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 FreeSpaceCheck added in v1.3.0

type FreeSpaceCheck struct {
	MinimumBytes uint64
	Path         string
}

FreeSpaceCheck checks the available disk space on a path

func (FreeSpaceCheck) Check added in v1.3.0

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

Check returns true if the path has enough free space. Otherwise return false.

type PackageCheck added in v1.3.0

type PackageCheck struct {
	PackageQuery         PackageQuery
	PackageManager       PackageManager
	InstallationDisabled bool
}

The PackageCheck uses the operating system to determine whether a package is installed.

func (PackageCheck) Check added in v1.3.0

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

Check returns true if the package is installed. If pkg installation is disabled, we would like to check if the package is available for install. However, there is no guarantee that the node will have the kismatic package repo configured. For this reason, this check is a no-op when package installation is disabled.

type PackageManager

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

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

func NewPackageManager

func NewPackageManager(distro Distro) (PackageManager, error)

NewPackageManager returns a package manager for the given distribution

type PackageQuery

type PackageQuery struct {
	Name       string
	Version    string
	AnyVersion bool
}

PackageQuery is a query for finding a package

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