informers

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2021 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bootstrapper

type Bootstrapper struct {
	// contains filtered or unexported fields
}

Bootstrapper builds an InformerSet from scratch

func NewBootstrapper

func NewBootstrapper(config *Config) *Bootstrapper

NewBootstrapper creates new Bootstrapper

type ChannelCallbackConfig

type ChannelCallbackConfig struct {
	Method          string `json:"method,omitempty" yaml:"method,omitempty"`
	URL             string `json:"url" yaml:"url"`
	Proxy           string `json:"proxy,omitempty" yaml:"proxy,omitempty"`
	UseTemplate     bool   `json:"useTemplate,omitempty" yaml:"useTemplate,omitempty"`
	AddedTemplate   string `json:"addedTemplate,omitempty" yaml:"addedTemplate,omitempty"`
	DeletedTemplate string `json:"deletedTemplate,omitempty" yaml:"deletedTemplate,omitempty"`
	UpdatedTemplate string `json:"updatedTemplate,omitempty" yaml:"updatedTemplate,omitempty"`
}

ChannelCallbackConfig is config for ChannelCallback, read from config file

type ChannelConfig

type ChannelConfig struct {
	// Type is the type of the channel
	Type channels.ChannelType `json:"type" yaml:"type"`

	Callback *ChannelCallbackConfig `json:"callback,omitempty" yaml:"callback,omitempty"`
	Dingtalk *ChannelDingtalkConfig `json:"dingtalk,omitempty" yaml:"dingtalk,omitempty"`
	Flock    *ChannelFlockConfig    `json:"flock,omitempty" yaml:"flock,omitempty"`
	Print    *ChannelPrintConfig    `json:"print,omitempty" yaml:"print,omitempty"`
	Slack    *ChannelSlackConfig    `json:"slack,omitempty" yaml:"slack,omitempty"`
	Telegram *ChannelTelegramConfig `json:"telegram,omitempty" yaml:"telegram,omitempty"`
}

ChannelConfig defines a channel to receive notifications

type ChannelDingtalkConfig

type ChannelDingtalkConfig struct {
	WebhookURL      string   `json:"webhookURL" yaml:"webhookURL"`
	Proxy           string   `json:"proxy,omitempty" yaml:"proxy,omitempty"`
	AtMobiles       []string `json:"atMobiles,omitempty" yaml:"atMobiles,omitempty"`
	AtAll           bool     `json:"atAll,omitempty" yaml:"atAll,omitempty"`
	AddedTemplate   string   `json:"addedTemplate,omitempty" yaml:"addedTemplate,omitempty"`
	DeletedTemplate string   `json:"deletedTemplate,omitempty" yaml:"deletedTemplate,omitempty"`
	UpdatedTemplate string   `json:"updatedTemplate,omitempty" yaml:"updatedTemplate,omitempty"`
}

ChannelDingtalkConfig is config for ChannelDingtalk, read from config file

type ChannelFlockConfig

type ChannelFlockConfig struct {
	URL             string `json:"url" yaml:"url"`
	Proxy           string `json:"proxy,omitempty" yaml:"proxy,omitempty"`
	TitleTemplate   string `json:"titleTemplate,omitempty" yaml:"titleTemplate,omitempty"`
	AddedTemplate   string `json:"addedTemplate,omitempty" yaml:"addedTemplate,omitempty"`
	DeletedTemplate string `json:"deletedTemplate,omitempty" yaml:"deletedTemplate,omitempty"`
	UpdatedTemplate string `json:"updatedTemplate,omitempty" yaml:"updatedTemplate,omitempty"`
}

ChannelFlockConfig is config for ChannelFlock, read from config file

type ChannelName

type ChannelName = channels.ChannelName

ChannelName is an alias to channels.ChannelName

type ChannelPrintConfig

type ChannelPrintConfig struct {
	Writer          string `json:"writer" yaml:"writer"`
	UseTemplate     bool   `json:"useTemplate,omitempty" yaml:"useTemplate,omitempty"`
	AddedTemplate   string `json:"addedTemplate,omitempty" yaml:"addedTemplate,omitempty"`
	DeletedTemplate string `json:"deletedTemplate,omitempty" yaml:"deletedTemplate,omitempty"`
	UpdatedTemplate string `json:"updatedTemplate,omitempty" yaml:"updatedTemplate,omitempty"`
}

ChannelPrintConfig is config for ChannelPrint, read from config file

type ChannelSlackConfig

type ChannelSlackConfig struct {
	Token           string `json:"token" yaml:"token"`
	Proxy           string `json:"proxy,omitempty" yaml:"proxy,omitempty"`
	WebhookURL      string `json:"webhookURL" yaml:"webhookURL"`
	TitleTemplate   string `json:"titleTemplate,omitempty" yaml:"titleTemplate,omitempty"`
	AddedTemplate   string `json:"addedTemplate,omitempty" yaml:"addedTemplate,omitempty"`
	DeletedTemplate string `json:"deletedTemplate,omitempty" yaml:"deletedTemplate,omitempty"`
	UpdatedTemplate string `json:"updatedTemplate,omitempty" yaml:"updatedTemplate,omitempty"`
}

ChannelSlackConfig is config for ChannelSlack, read from config file

type ChannelTelegramConfig

type ChannelTelegramConfig struct {
	Token           string   `json:"token" yaml:"token"`
	ChatIDs         []string `json:"chatIDs" yaml:"chatIDs"`
	Proxy           string   `json:"proxy,omitempty" yaml:"proxy,omitempty"`
	AddedTemplate   string   `json:"addedTemplate,omitempty" yaml:"addedTemplate,omitempty"`
	DeletedTemplate string   `json:"deletedTemplate,omitempty" yaml:"deletedTemplate,omitempty"`
	UpdatedTemplate string   `json:"updatedTemplate,omitempty" yaml:"updatedTemplate,omitempty"`
}

ChannelTelegramConfig is config for ChannelTelegram, read from config file

type ChannelToProcess

type ChannelToProcess struct {
	ChannelName         ChannelName
	EventProcessContext *channels.EventProcessContext
}

ChannelToProcess defines a channel to process

type Config

type Config struct {
	KubeConfig string

	ConfigFile *ConfigFile

	SaveEvent  bool
	EventStore event_store.Interface
}

func (*Config) Validate

func (c *Config) Validate() error

type ConfigFile

type ConfigFile struct {
	// Channels defines channels that receive notifications
	Channels map[ChannelName]ChannelConfig `json:"channels" yaml:"channels"`

	// Namespaces defines namespaces and resources to watch
	Namespaces []NamespaceConfig `json:"namespaces" yaml:"namespaces"`

	// DefaultChannelNames defines default channels
	DefaultChannelNames []ChannelName `json:"defaultChannelNames,omitempty" yaml:"defaultChannelNames,omitempty"`

	// DefaultWorkers is the default number of workers
	DefaultWorkers int `json:"defaultWorkers,omitempty" yaml:"defaultWorkers,omitempty"`

	// DefaultMaxRetries is the default max retry times
	DefaultMaxRetries int `json:"defaultMaxRetries,omitempty" yaml:"defaultMaxRetries,omitempty"`

	// MinResyncPeriod is the resync period in reflectors;
	// actual resync period will be random between MinResyncPeriod and 2*minResyncPeriod.
	MinResyncPeriod string `json:"minResyncPeriod,omitempty" yaml:"minResyncPeriod,omitempty"`
}

ConfigFile is struct of informers config file, order of fields affects order of fields in JSON

func LoadConfigFromFile

func LoadConfigFromFile(file string) (*ConfigFile, error)

LoadConfigFromFile loads config from file

func (*ConfigFile) Validate

func (c *ConfigFile) Validate() error

Validate validates ConfigFile values

type Informer

type Informer struct {
	// ID is an unique string to identify instances
	ID string

	// Resource is the resource to watch, e.g. "deployments.v1.apps"
	Resource string

	// GVR is group version kind of Resource
	GVR schema.GroupVersionResource

	// UpdateOn defines fields to watch, used with NoticeWhenUpdated
	UpdateOn []string

	// ChannelMap defines channels to send notification
	ChannelMap channels.ChannelMap

	// Queue is a rate limiting queue
	Queue workqueue.RateLimitingInterface

	// Workers is number of workers
	Workers int

	// MaxRetries defines max retry times
	MaxRetries int
	// contains filtered or unexported fields
}

func (*Informer) RunWorker

func (i *Informer) RunWorker()

func (*Informer) ShutDown

func (i *Informer) ShutDown()

type InformerSet

type InformerSet struct {
	ResourceBuilder   resourcebuilder.Interface
	Factories         []dynamicinformer.DynamicSharedInformerFactory
	ResourceInformers []*Informer
}

func Setup

func Setup(config Config) (*InformerSet, error)

Setup setups new InformerSet

func (*InformerSet) Shutdown

func (set *InformerSet) Shutdown()

func (*InformerSet) Start

func (set *InformerSet) Start(stopCh <-chan struct{}) error

type Interface

type Interface interface {
	// Start starts all informers registered,
	// Start is non-blocking, you should always call Shutdown before exit.
	Start(stopCh <-chan struct{}) error

	// Shutdown should be called before exit.
	Shutdown()
}

type NamespaceConfig

type NamespaceConfig struct {
	// Namespace is the namespace to watch, default to "", which means all namespaces
	Namespace string `json:"namespace" yaml:"namespace"`

	// Resources is the resources you want to watch
	Resources []ResourceConfig `json:"resources" yaml:"resources"`

	// DefaultChannelNames defines default channels in this namespace
	DefaultChannelNames []ChannelName `json:"defaultChannelNames,omitempty" yaml:"defaultChannelNames,omitempty"`

	// DefaultWorkers is the default number of workers in this namespace
	DefaultWorkers int `json:"defaultWorkers,omitempty" yaml:"defaultWorkers,omitempty"`

	// DefaultMaxRetries is the default max retry times in this namespace
	DefaultMaxRetries int `json:"defaultMaxRetries,omitempty" yaml:"defaultMaxRetries,omitempty"`

	// MinResyncPeriod is the resync period in reflectors in this namespace;
	// actual resync period will be random between MinResyncPeriod and 2*minResyncPeriod.
	MinResyncPeriod string `json:"minResyncPeriod,omitempty" yaml:"minResyncPeriod,omitempty"`
}

type ResourceConfig

type ResourceConfig struct {
	// Name is an unique value for this resource,
	// the controller, server and query command use Name to query events
	Name string `json:"name" yaml:"name"`

	// Resource is the resource to watch, e.g. "deployments.v1.apps"
	Resource string `json:"resource" yaml:"resource"`

	// NoticeWhenAdded determine whether to notice when a resource is added
	NoticeWhenAdded bool `json:"noticeWhenAdded" yaml:"noticeWhenAdded"`

	// NoticeWhenDeleted determine whether to notice when a resource is deleted
	NoticeWhenDeleted bool `json:"noticeWhenDeleted" yaml:"noticeWhenDeleted"`

	// NoticeWhenUpdated determine whether to notice when a resource is updated,
	// When UpdateOn is not nil, only notice when fields in UpdateOn is changed
	NoticeWhenUpdated bool `json:"noticeWhenUpdated" yaml:"noticeWhenUpdated"`

	// UpdateOn defines fields to watch, used with NoticeWhenUpdated
	UpdateOn []string `json:"updateOn,omitempty" yaml:"updateOn,omitempty"`

	// ChannelNames defines channels to send notification
	ChannelNames []ChannelName `json:"channelNames,omitempty" yaml:"channelNames,omitempty"`

	// ResyncPeriod is the resync period in reflectors for this resource
	ResyncPeriod string `json:"resyncPeriod,omitempty" yaml:"resyncPeriod,omitempty"`

	// Workers is the number of workers
	Workers int `json:"workers,omitempty" yaml:"workers,omitempty"`

	// MaxRetries is the max retry times
	MaxRetries int `json:"maxRetries,omitempty" yaml:"maxRetries,omitempty"`
}

type ResyncPeriodFunc

type ResyncPeriodFunc func() time.Duration

ResyncPeriodFunc is a function to build resync period (time.Duration)

Jump to

Keyboard shortcuts

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