config

package
v1.6.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AllNamespaceIndicator represents a keyword for allowing all Kubernetes Namespaces.
	AllNamespaceIndicator = ".*"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Button added in v1.2.0

type Button struct {
	CommandTpl  string `yaml:"commandTpl"`
	DisplayName string `yaml:"displayName"`
}

type Commands

type Commands struct {
	Verbs     []string `yaml:"verbs"`
	Resources []string `yaml:"resources"`
}

Commands contains allowed verbs and resources

type Config

type Config struct {
	ExtraButtons         []ExtraButtons     `yaml:"extraButtons"`
	InformerResyncPeriod time.Duration      `yaml:"informerResyncPeriod"`
	Log                  config.Logger      `yaml:"log"`
	Recommendations      *Recommendations   `yaml:"recommendations"`
	Event                *KubernetesEvent   `yaml:"event"`
	Resources            []Resource         `yaml:"resources" validate:"dive"`
	Commands             Commands           `yaml:"commands"`
	Namespaces           *RegexConstraints  `yaml:"namespaces"`
	Annotations          *map[string]string `yaml:"annotations"`
	Labels               *map[string]string `yaml:"labels"`
	Filters              *Filters           `yaml:"filters"`
}

Config Kubernetes configuration

func MergeConfigs

func MergeConfigs(configs []*source.Config) (Config, error)

MergeConfigs merges all input configuration.

type EventType

type EventType string

EventType to watch

const (
	// CreateEvent when resource is created
	CreateEvent EventType = "create"
	// UpdateEvent when resource is updated
	UpdateEvent EventType = "update"
	// DeleteEvent when resource deleted
	DeleteEvent EventType = "delete"
	// ErrorEvent on errors in resources
	ErrorEvent EventType = "error"
	// WarningEvent for warning events
	WarningEvent EventType = "warning"
	// NormalEvent for Normal events
	NormalEvent EventType = "normal"
	// InfoEvent for insignificant Info events
	InfoEvent EventType = "info"
	// AllEvent to watch all events
	AllEvent EventType = "all"
)

func (EventType) String

func (eventType EventType) String() string

type ExtraButtons added in v1.2.0

type ExtraButtons struct {
	Enabled bool    `yaml:"enabled"`
	Trigger Trigger `yaml:"trigger"`
	Button  Button  `yaml:"button"`
}

type Filters

type Filters struct {
	// ObjectAnnotationChecker enables support for `botkube.io/disable` resource annotation.
	ObjectAnnotationChecker bool `yaml:"objectAnnotationChecker"`

	// NodeEventsChecker filters out Node-related events that are not important.
	NodeEventsChecker bool `yaml:"nodeEventsChecker"`
}

Filters contains configuration for built-in filters.

type IngressRecommendations

type IngressRecommendations struct {
	// BackendServiceValid notifies about Ingress resources with invalid backend service reference.
	BackendServiceValid *bool `yaml:"backendServiceValid,omitempty"`

	// TLSSecretValid notifies about Ingress resources with invalid TLS secret reference.
	TLSSecretValid *bool `yaml:"tlsSecretValid,omitempty"`
}

IngressRecommendations contains configuration for ingress recommendations.

type KubernetesEvent

type KubernetesEvent struct {
	Reason  RegexConstraints             `yaml:"reason"`
	Message RegexConstraints             `yaml:"message"`
	Types   KubernetesResourceEventTypes `yaml:"types"`
}

KubernetesEvent contains configuration for Kubernetes events.

func (KubernetesEvent) AreConstraintsDefined

func (e KubernetesEvent) AreConstraintsDefined() bool

AreConstraintsDefined checks if any of the event constraints are defined.

type KubernetesResourceEventTypes

type KubernetesResourceEventTypes []EventType

KubernetesResourceEventTypes contains events to watch for a resource.

type Level

type Level string

Level type to store event levels

const (
	// Info level
	Info    Level = "info"
	Success Level = "success"
	// Error level
	Error Level = "error"
)

type PodRecommendations

type PodRecommendations struct {
	// NoLatestImageTag notifies about Pod containers that use `latest` tag for images.
	NoLatestImageTag *bool `yaml:"noLatestImageTag,omitempty"`

	// LabelsSet notifies about Pod resources created without labels.
	LabelsSet *bool `yaml:"labelsSet,omitempty"`
}

PodRecommendations contains configuration for pods recommendations.

type Recommendations

type Recommendations struct {
	Ingress IngressRecommendations `yaml:"ingress"`
	Pod     PodRecommendations     `yaml:"pod"`
}

Recommendations contains configuration for various recommendation insights.

type RegexConstraints

type RegexConstraints struct {
	// Include contains a list of allowed values.
	// It can also contain a regex expressions:
	//  - ".*" - to specify all values.
	Include []string `yaml:"include"`

	// Exclude contains a list of values to be ignored even if allowed by Include.
	// It can also contain a regex expressions:
	//  - "test-.*" - to specify all values with `test-` prefix.
	Exclude []string `yaml:"exclude,omitempty"`
}

RegexConstraints contains a list of allowed and excluded values.

func (*RegexConstraints) AreConstraintsDefined

func (r *RegexConstraints) AreConstraintsDefined() bool

AreConstraintsDefined checks whether the RegexConstraints has any Include/Exclude configuration.

func (*RegexConstraints) IsAllowed

func (r *RegexConstraints) IsAllowed(value string) (bool, error)

IsAllowed checks if a given value is allowed based on the config. Firstly, it checks if the value is excluded. If not, then it checks if the value is included.

type Resource

type Resource struct {
	Type          string            `yaml:"type"`
	Name          RegexConstraints  `yaml:"name"`
	Namespaces    RegexConstraints  `yaml:"namespaces"`
	Annotations   map[string]string `yaml:"annotations"`
	Labels        map[string]string `yaml:"labels"`
	Event         KubernetesEvent   `yaml:"event"`
	UpdateSetting UpdateSetting     `yaml:"updateSetting"`
}

Resource contains resources to watch

type Trigger added in v1.2.0

type Trigger struct {
	Type []string `yaml:"type"`
}

type UpdateSetting

type UpdateSetting struct {
	Fields      []string `yaml:"fields"`
	IncludeDiff bool     `yaml:"includeDiff"`
}

UpdateSetting struct defines updateEvent fields specification

Jump to

Keyboard shortcuts

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