config

package
v0.0.0-...-cd37cee Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: GPL-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
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
}

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 NewRuntimeConfig(
	esLaunch func(source *Source),
	logs *logging.Logging,
	db *icingadb.DB,
) *RuntimeConfig

func (*RuntimeConfig) GetContact

func (r *RuntimeConfig) GetContact(username string) *recipient.Contact

GetContact returns *recipient.Contact by the given username. 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) RLock

func (r *RuntimeConfig) RLock()

RLock locks the config for reading.

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 {
	ID   int64  `db:"id"`
	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.

Jump to

Keyboard shortcuts

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