Documentation ¶
Index ¶
- Constants
- func FromEnvOrFlag() []string
- func LoadWithDefaults(getCfgPaths PathsGetter) (*Config, LoadWithDefaultsDetails, error)
- func RegisterFlags(flags *pflag.FlagSet)
- type AWSSigning
- type Analytics
- type BotBindings
- type ChannelBindingsByID
- type ChannelBindingsByName
- type CommPlatformIntegration
- type Commands
- type Communications
- type Config
- type Discord
- type ELSIndex
- type Elasticsearch
- type EventType
- type Executors
- type Identifiable
- type IdentifiableMap
- type IngressRecommendations
- type IntegrationType
- type Kubectl
- type KubernetesResourceEvents
- type KubernetesResources
- type KubernetesSource
- type Level
- type LoadWithDefaultsDetails
- type Mattermost
- type Namespaces
- type Notification
- type NotificationType
- type PathsGetter
- type PodRecommendations
- type Recommendations
- type Resource
- type Settings
- type SinkBindings
- type Slack
- type Sources
- type Teams
- type UpdateSetting
- type ValidateResult
- type Webhook
Constants ¶
const (
// AllNamespaceIndicator represents a keyword for allowing all Kubernetes Namespaces.
AllNamespaceIndicator = ".*"
)
Variables ¶
This section is empty.
Functions ¶
func FromEnvOrFlag ¶ added in v0.13.0
func FromEnvOrFlag() []string
FromEnvOrFlag resolves and returns paths for config files. It reads them the 'BOTKUBE_CONFIG_PATHS' env variable. If not found, then it uses '--config' flag.
func LoadWithDefaults ¶ added in v0.13.0
func LoadWithDefaults(getCfgPaths PathsGetter) (*Config, LoadWithDefaultsDetails, error)
LoadWithDefaults loads new configuration from files and environment variables.
func RegisterFlags ¶ added in v0.13.0
RegisterFlags registers config related flags.
Types ¶
type AWSSigning ¶ added in v0.13.0
type AWSSigning struct { Enabled bool `yaml:"enabled"` AWSRegion string `yaml:"awsRegion"` RoleArn string `yaml:"roleArn"` }
AWSSigning contains AWS configurations
type Analytics ¶ added in v0.13.0
type Analytics struct { InstallationID string `yaml:"installationID"` Disable bool `yaml:"disable"` }
Analytics contains configuration parameters for analytics collection.
type BotBindings ¶ added in v0.13.0
BotBindings contains configuration for possible Bot bindings.
type ChannelBindingsByID ¶ added in v0.13.0
type ChannelBindingsByID struct { ID string `yaml:"id"` Bindings BotBindings `yaml:"bindings"` }
ChannelBindingsByID contains configuration bindings per channel.
func (ChannelBindingsByID) Identifier ¶ added in v0.13.0
func (c ChannelBindingsByID) Identifier() string
Identifier returns ChannelBindingsByID identifier.
type ChannelBindingsByName ¶ added in v0.13.0
type ChannelBindingsByName struct { Name string `yaml:"name"` Bindings BotBindings `yaml:"bindings"` }
ChannelBindingsByName contains configuration bindings per channel.
func (ChannelBindingsByName) Identifier ¶ added in v0.13.0
func (c ChannelBindingsByName) Identifier() string
Identifier returns ChannelBindingsByID identifier.
type CommPlatformIntegration ¶ added in v0.13.0
type CommPlatformIntegration string
CommPlatformIntegration defines integrations with communication platforms.
const ( // SlackCommPlatformIntegration defines Slack integration. SlackCommPlatformIntegration CommPlatformIntegration = "slack" // MattermostCommPlatformIntegration defines Mattermost integration. MattermostCommPlatformIntegration CommPlatformIntegration = "mattermost" // TeamsCommPlatformIntegration defines Teams integration. TeamsCommPlatformIntegration CommPlatformIntegration = "teams" // DiscordCommPlatformIntegration defines Discord integration. DiscordCommPlatformIntegration CommPlatformIntegration = "discord" //ElasticsearchCommPlatformIntegration defines Elasticsearch integration. ElasticsearchCommPlatformIntegration CommPlatformIntegration = "elasticsearch" // WebhookCommPlatformIntegration defines an outgoing webhook integration. WebhookCommPlatformIntegration CommPlatformIntegration = "webhook" )
type Communications ¶
type Communications struct { Slack Slack `yaml:"slack"` Mattermost Mattermost `yaml:"mattermost"` Discord Discord `yaml:"discord"` Teams Teams `yaml:"teams"` Webhook Webhook `yaml:"webhook"` Elasticsearch Elasticsearch `yaml:"elasticsearch"` }
Communications channels to send events to
type Config ¶
type Config struct { Sources map[string]Sources `yaml:"sources" validate:"dive"` Executors map[string]Executors `yaml:"executors" validate:"dive"` Communications map[string]Communications `yaml:"communications" validate:"required,min=1"` Analytics Analytics `yaml:"analytics"` Settings Settings `yaml:"settings"` }
Config structure of configuration yaml file
type Discord ¶ added in v0.13.0
type Discord struct { Enabled bool `yaml:"enabled"` Token string `yaml:"token"` BotID string `yaml:"botID"` Channels IdentifiableMap[ChannelBindingsByID] `yaml:"channels" validate:"required,eq=1"` Notification Notification `yaml:"notification,omitempty"` }
Discord configuration for authentication and send notifications
type ELSIndex ¶ added in v0.13.0
type ELSIndex struct { Name string `yaml:"name"` Type string `yaml:"type"` Shards int `yaml:"shards"` Replicas int `yaml:"replicas"` Bindings SinkBindings `yaml:"bindings"` }
ELSIndex settings for ELS
type Elasticsearch ¶ added in v0.13.0
type Elasticsearch struct { Enabled bool `yaml:"enabled"` Username string `yaml:"username"` Password string `yaml:"password"` Server string `yaml:"server"` SkipTLSVerify bool `yaml:"skipTLSVerify"` AWSSigning AWSSigning `yaml:"awsSigning"` Indices map[string]ELSIndex `yaml:"indices" validate:"required,eq=1"` }
Elasticsearch config auth settings
type EventType ¶ added in v0.8.0
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" )
type Executors ¶ added in v0.13.0
type Executors struct {
Kubectl Kubectl `yaml:"kubectl"`
}
Executors contains executors configuration parameters.
type Identifiable ¶ added in v0.13.0
type Identifiable interface {
Identifier() string
}
Identifiable exports an Identifier method.
type IdentifiableMap ¶ added in v0.13.0
type IdentifiableMap[T Identifiable] map[string]T
IdentifiableMap provides an option to construct an indexable map for identifiable items.
func (IdentifiableMap[T]) GetByIdentifier ¶ added in v0.13.0
func (t IdentifiableMap[T]) GetByIdentifier(val string) (T, bool)
GetByIdentifier gets an item from a map by identifier.
type IngressRecommendations ¶ added in v0.13.0
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 IntegrationType ¶ added in v0.13.0
type IntegrationType string
IntegrationType describes the type of integration with a communication platform.
const ( // BotIntegrationType describes two-way integration. BotIntegrationType IntegrationType = "bot" // SinkIntegrationType describes one-way integration. SinkIntegrationType IntegrationType = "sink" )
type Kubectl ¶ added in v0.13.0
type Kubectl struct { Namespaces Namespaces `yaml:"namespaces,omitempty"` Enabled bool `yaml:"enabled"` Commands Commands `yaml:"commands,omitempty"` DefaultNamespace string `yaml:"defaultNamespace,omitempty"` RestrictAccess *bool `yaml:"restrictAccess,omitempty"` }
Kubectl configuration for executing commands inside cluster
type KubernetesResourceEvents ¶ added in v0.13.0
type KubernetesResourceEvents []EventType
KubernetesResourceEvents contains events to watch for a resource.
func (*KubernetesResourceEvents) Contains ¶ added in v0.13.0
func (e *KubernetesResourceEvents) Contains(eventType EventType) bool
Contains checks if event is contained in the events slice. If the slice contains AllEvent, then the result is true.
type KubernetesResources ¶ added in v0.13.0
type KubernetesResources []Resource
KubernetesResources contains configuration for Kubernetes resources.
type KubernetesSource ¶ added in v0.13.0
type KubernetesSource struct { Recommendations Recommendations `yaml:"recommendations"` Resources KubernetesResources `yaml:"resources" validate:"dive"` Namespaces Namespaces `yaml:"namespaces"` }
KubernetesSource contains configuration for Kubernetes sources.
type LoadWithDefaultsDetails ¶ added in v0.13.0
LoadWithDefaultsDetails holds the LoadWithDefaults function details.
type Mattermost ¶ added in v0.7.0
type Mattermost struct { Enabled bool `yaml:"enabled"` BotName string `yaml:"botName"` URL string `yaml:"url"` Token string `yaml:"token"` Team string `yaml:"team"` Channels IdentifiableMap[ChannelBindingsByName] `yaml:"channels" validate:"required,eq=1"` Notification Notification `yaml:"notification,omitempty"` }
Mattermost configuration to authentication and send notifications
type Namespaces ¶ added in v0.13.0
type Namespaces struct { // Include contains a list of allowed Namespaces. // It can also contain a regex expressions: // - ".*" - to specify all Namespaces. Include []string `yaml:"include"` // Exclude contains a list of Namespaces to be ignored even if allowed by Include. // It can also contain a regex expressions: // - "test-.*" - to specif all Namespaces with `test-` prefix. Exclude []string `yaml:"exclude,omitempty"` }
Namespaces provides an option to include and exclude given Namespaces.
func (*Namespaces) IsAllowed ¶ added in v0.13.0
func (n *Namespaces) IsAllowed(givenNs string) bool
IsAllowed checks if a given Namespace is allowed based on the config.
func (*Namespaces) IsConfigured ¶ added in v0.13.0
func (n *Namespaces) IsConfigured() bool
IsConfigured checks whether the Namespace has any Include/Exclude configuration.
type Notification ¶ added in v0.13.0
type Notification struct {
Type NotificationType
}
Notification holds notification configuration.
type NotificationType ¶ added in v0.13.0
type NotificationType string
NotificationType to change notification type
const ( // ShortNotification is the default NotificationType ShortNotification NotificationType = "short" // LongNotification for short events notification LongNotification NotificationType = "long" )
type PathsGetter ¶ added in v0.13.0
type PathsGetter func() []string
PathsGetter returns the list of absolute paths to the config files.
type PodRecommendations ¶ added in v0.13.0
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 ¶ added in v0.13.0
type Recommendations struct { Ingress IngressRecommendations `yaml:"ingress"` Pod PodRecommendations `yaml:"pod"` }
Recommendations contains configuration for various recommendation insights.
type Resource ¶
type Resource struct { Name string `yaml:"name"` Namespaces Namespaces `yaml:"namespaces"` Events KubernetesResourceEvents `yaml:"events"` UpdateSetting UpdateSetting `yaml:"updateSetting"` }
Resource contains resources to watch
type Settings ¶ added in v0.2.0
type Settings struct { ClusterName string `yaml:"clusterName"` ConfigWatcher bool `yaml:"configWatcher"` UpgradeNotifier bool `yaml:"upgradeNotifier"` MetricsPort string `yaml:"metricsPort"` Log struct { Level string `yaml:"level"` DisableColors bool `yaml:"disableColors"` } `yaml:"log"` InformersResyncPeriod time.Duration `yaml:"informersResyncPeriod"` Kubeconfig string `yaml:"kubeconfig"` }
Settings contains BotKube's related configuration.
type SinkBindings ¶ added in v0.13.0
type SinkBindings struct {
Sources []string `yaml:"sources"`
}
SinkBindings contains configuration for possible Sink bindings.
type Slack ¶
type Slack struct { Enabled bool `yaml:"enabled"` Channels IdentifiableMap[ChannelBindingsByName] `yaml:"channels" validate:"required,eq=1"` Notification Notification `yaml:"notification,omitempty"` Token string `yaml:"token,omitempty"` }
Slack configuration to authentication and send notifications
type Sources ¶ added in v0.13.0
type Sources struct {
Kubernetes KubernetesSource `yaml:"kubernetes"`
}
Sources contains configuration for BotKube app sources.
type Teams ¶ added in v0.13.0
type Teams struct { Enabled bool `yaml:"enabled"` BotName string `yaml:"botName,omitempty"` AppID string `yaml:"appID,omitempty"` AppPassword string `yaml:"appPassword,omitempty"` Port string `yaml:"port"` MessagePath string `yaml:"messagePath,omitempty"` // TODO: Be consistent with other communicators when MS Teams support multiple channels //Channels IdentifiableMap[ChannelBindingsByName] `yaml:"channels"` Bindings BotBindings `yaml:"bindings"` Notification Notification `yaml:"notification,omitempty"` }
Teams creds for authentication with MS Teams
type UpdateSetting ¶ added in v0.13.0
UpdateSetting struct defines updateEvent fields specification
type ValidateResult ¶ added in v0.13.0
type ValidateResult struct { Criticals *multierror.Error Warnings *multierror.Error }
ValidateResult holds the validation results.
func ValidateStruct ¶ added in v0.13.0
func ValidateStruct(in any) (ValidateResult, error)
ValidateStruct validates a given struct based on the `validate` field tag.
type Webhook ¶ added in v0.13.0
type Webhook struct { Enabled bool `yaml:"enabled"` URL string `yaml:"url"` // TODO: not used yet. Bindings SinkBindings }
Webhook configuration to send notifications