Documentation
¶
Index ¶
- Constants
- type ConfigSet
- type IncrementalConfigurable
- type IncrementalConfigurableInitAndValidatable
- type RuntimeConfig
- func (r *RuntimeConfig) GetContact(username string) *recipient.Contact
- func (r *RuntimeConfig) GetRecipient(k recipient.Key) recipient.Recipient
- func (r *RuntimeConfig) GetRuleEscalation(escalationID int64) *rule.Escalation
- func (r *RuntimeConfig) GetSourceFromCredentials(user, pass string, logger *logging.Logger) *Source
- func (r *RuntimeConfig) PeriodicUpdates(ctx context.Context, interval time.Duration)
- func (r *RuntimeConfig) RLock()
- func (r *RuntimeConfig) RUnlock()
- func (r *RuntimeConfig) UpdateFromDatabase(ctx context.Context) error
- type Source
Constants ¶
const SourceTypeIcinga2 = "icinga2"
SourceTypeIcinga2 represents the "icinga2" Source Type for Event Stream API sources.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigSet ¶
type ConfigSet struct { Channels map[int64]*channel.Channel Contacts map[int64]*recipient.Contact ContactAddresses map[int64]*recipient.Address Groups map[int64]*recipient.Group TimePeriods map[int64]*timeperiod.TimePeriod Schedules map[int64]*recipient.Schedule Rules map[int64]*rule.Rule Sources map[int64]*Source // contains filtered or unexported fields }
type IncrementalConfigurable ¶
type IncrementalConfigurable[PK comparable] interface { zapcore.ObjectMarshaler // GetPrimaryKey returns the primary key value. GetPrimaryKey() PK // GetChangedAt returns the changed_at value. GetChangedAt() types.UnixMilli // IsDeleted returns if this entry was marked as deleted. IsDeleted() bool }
IncrementalConfigurable specifies Getter methods required for types supporting incremental configuration loading.
type IncrementalConfigurableInitAndValidatable ¶
type IncrementalConfigurableInitAndValidatable interface { // IncrementalInitAndValidate allows both to initialize and validates with an optional error. // // If an error is returned, the incrementalFetch function aborts the element in question. IncrementalInitAndValidate() error }
IncrementalConfigurableInitAndValidatable defines a single method for new and updated elements to allow both initialization and validation, to be used within incrementalFetch.
type RuntimeConfig ¶
type RuntimeConfig struct { // ConfigSet is the current live config. It is embedded to allow direct access to its members. // Accessing it requires a lock that is obtained with RLock() and released with RUnlock(). ConfigSet // EventStreamLaunchFunc is a callback to launch an Event Stream API Client. // This became necessary due to circular imports, either with the incident or icinga2 package. EventStreamLaunchFunc func(source *Source) // contains filtered or unexported fields }
RuntimeConfig stores the runtime representation of the configuration present in the database.
func NewRuntimeConfig ¶
func (*RuntimeConfig) GetContact ¶
func (r *RuntimeConfig) GetContact(username string) *recipient.Contact
GetContact returns *recipient.Contact by the given username (case-insensitive). Returns nil when the given username doesn't exist.
func (*RuntimeConfig) GetRecipient ¶
func (r *RuntimeConfig) GetRecipient(k recipient.Key) recipient.Recipient
func (*RuntimeConfig) GetRuleEscalation ¶
func (r *RuntimeConfig) GetRuleEscalation(escalationID int64) *rule.Escalation
GetRuleEscalation returns a *rule.Escalation by the given id. Returns nil if there is no rule escalation with given id.
func (*RuntimeConfig) GetSourceFromCredentials ¶
func (r *RuntimeConfig) GetSourceFromCredentials(user, pass string, logger *logging.Logger) *Source
GetSourceFromCredentials verifies a credential pair against known Sources.
This method returns either a *Source or a nil pointer and logs the cause to the given logger. This is in almost all cases a debug logging message, except when something server-side is wrong, e.g., the hash is invalid.
func (*RuntimeConfig) PeriodicUpdates ¶
func (r *RuntimeConfig) PeriodicUpdates(ctx context.Context, interval time.Duration)
func (*RuntimeConfig) RUnlock ¶
func (r *RuntimeConfig) RUnlock()
RUnlock releases a lock obtained by RLock().
func (*RuntimeConfig) UpdateFromDatabase ¶
func (r *RuntimeConfig) UpdateFromDatabase(ctx context.Context) error
type Source ¶
type Source struct { baseconf.IncrementalPkDbEntry[int64] `db:",inline"` Type string `db:"type"` Name string `db:"name"` ListenerPasswordHash types.String `db:"listener_password_hash"` Icinga2BaseURL types.String `db:"icinga2_base_url"` Icinga2AuthUser types.String `db:"icinga2_auth_user"` Icinga2AuthPass types.String `db:"icinga2_auth_pass"` Icinga2CAPem types.String `db:"icinga2_ca_pem"` Icinga2CommonName types.String `db:"icinga2_common_name"` Icinga2InsecureTLS types.Bool `db:"icinga2_insecure_tls"` // Icinga2SourceConf for Event Stream API sources, only if Source.Type == SourceTypeIcinga2. Icinga2SourceCancel context.CancelFunc `db:"-" json:"-"` }
Source entry within the ConfigSet to describe a source.
func (*Source) MarshalLogObject ¶
func (source *Source) MarshalLogObject(encoder zapcore.ObjectEncoder) error
MarshalLogObject implements the zapcore.ObjectMarshaler interface.