checks

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Error means that the diagnostic message should be fixed immediately
	Error Severity = "error"
	// Warning indicates that the diagnostic should be fixed but okay to ignore in some special cases
	Warning Severity = "warning"
	// Suggestion means that a user need not implement it, but is in line with the recommended best practices
	Suggestion Severity = "suggestion"
	// Pod identifies Kubernetes objects of kind `pod`
	Pod Kind = "pod"
	// PodTemplate identifies Kubernetes objects of kind `pod template`
	PodTemplate Kind = "pod template"
	// PersistentVolumeClaim identifies Kubernetes objects of kind `persistent volume claim`
	PersistentVolumeClaim Kind = "persistent volume claim"
	// ConfigMap identifies Kubernetes objects of kind `config map`
	ConfigMap Kind = "config map"
	// Service identifies Kubernetes objects of kind `service`
	Service Kind = "service"
	// Secret identifies Kubernetes objects of kind `secret`
	Secret Kind = "secret"
	// ServiceAccount identifies Kubernetes objects of kind `service account`
	ServiceAccount Kind = "service account"
	// PersistentVolume identifies Kubernetes objects of kind `persistent volume`
	PersistentVolume Kind = "persistent volume"
	// ValidatingWebhookConfiguration identifies Kubernetes objects of kind `validating webhook configuration`
	ValidatingWebhookConfiguration Kind = "validating webhook configuration"
	// MutatingWebhookConfiguration identifies Kubernetes objects of kind `mutating webhook configuration`
	MutatingWebhookConfiguration Kind = "mutating webhook configuration"
	// Node identifies a Kubernetes node object.
	Node Kind = "node"
	// VolumeSnapshot identifies a volume snapshot object
	VolumeSnapshot Kind = "volume snapshot"
	// VolumeSnapshotContent identifies a volume snapshot content object
	VolumeSnapshotContent Kind = "volume snapshot content"
	// CronJob identifies Kubernetes objects of kind `cron job`
	CronJob Kind = "cron job"
)

Variables

This section is empty.

Functions

func IsEnabled

func IsEnabled(name string, item *metav1.ObjectMeta) bool

IsEnabled inspects the object annotations to see if a check is disabled

func ListGroups

func ListGroups() []string

ListGroups returns the names of all registered check groups.

func Register

func Register(check Check) error

Register registers a check. This should be called from each check implementation's init().

Types

type Check

type Check interface {
	// Name returns a unique name for this check.
	Name() string
	// Groups returns a list of group names this check should be part of. It is
	// valid to return nil or an empty list if a check does not belong in any
	// groups.
	Groups() []string
	// Description returns a detailed human-readable description of what this
	// check does.
	Description() string
	// Run runs this check on a set of Kubernetes objects. It can return
	// warnings (low-priority problems) and errors (high-priority problems) as
	// well as an error value indicating that the check failed to run.
	Run(*kube.Objects) ([]Diagnostic, error)
}

Check is a check that can run on Kubernetes objects.

func Get

func Get(name string) (Check, error)

Get retrieves the specified check from the registry, throws an error if not found

func GetGroup

func GetGroup(name string) []Check

GetGroup returns the checks in a particular group.

func GetGroups

func GetGroups(groups []string) ([]Check, error)

GetGroups returns checks that belong to any of the specified group.

func List

func List() []Check

List returns all the registered checks.

type CheckFilter

type CheckFilter struct {
	IncludeGroups []string
	ExcludeGroups []string
	IncludeChecks []string
	ExcludeChecks []string
}

CheckFilter stores names of checks and groups that needs to be included or excluded while running checks

func NewCheckFilter

func NewCheckFilter(includeGroups, excludeGroups, includeChecks, excludeChecks []string) (CheckFilter, error)

NewCheckFilter is a constructor to initialize an instance of CheckFilter

func (CheckFilter) FilterChecks

func (c CheckFilter) FilterChecks() ([]Check, error)

FilterChecks filters all to return set of checks based on the CheckFilter

type CheckResult added in v0.1.1

type CheckResult struct {
	Diagnostics []Diagnostic
	Durations   map[string]time.Duration
}

CheckResult is the output returned by the Run function

func Run

func Run(ctx context.Context, client *kube.Client, checkFilter CheckFilter, diagnosticFilter DiagnosticFilter, objectFilter kube.ObjectFilter) (*CheckResult, error)

Run applies the filters and runs the resultant check list in parallel

type Diagnostic

type Diagnostic struct {
	Check    string
	Severity Severity
	Message  string
	Kind     Kind
	Object   *metav1.ObjectMeta
	Owners   []metav1.OwnerReference
	Details  string
}

Diagnostic encapsulates the information each check returns.

func (Diagnostic) String

func (d Diagnostic) String() string

type DiagnosticFilter

type DiagnosticFilter struct {
	Severity Severity
}

DiagnosticFilter indicates conditions to filter diagnostics on

type Kind

type Kind string

Kind represents the kind of k8s object the diagnoatic is about

type Severity

type Severity string

Severity identifies the level of priority for each diagnostic.

Directories

Path Synopsis
Package all imports all other check-containing packages, for the side-effect of having them registered in the check registry.
Package all imports all other check-containing packages, for the side-effect of having them registered in the check registry.

Jump to

Keyboard shortcuts

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