config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: GPL-2.0 Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

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
	Sources          map[int64]*Source
	Rules            map[int64]*rule.Rule
	// 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
	// contains filtered or unexported fields
}

RuntimeConfig stores the runtime representation of the configuration present in the database.

func NewRuntimeConfig

func NewRuntimeConfig(
	logs *logging.Logging,
	db *database.DB,
) *RuntimeConfig

func (*RuntimeConfig) GetRecipient

func (r *RuntimeConfig) GetRecipient(k recipient.Key) recipient.Recipient

func (*RuntimeConfig) GetRuleEntry added in v1.0.0

func (r *RuntimeConfig) GetRuleEntry(entryID int64) *rule.Entry

GetRuleEntry returns a *rule.Entry of the given id. Returns nil if there is no rule entry with the given id.

func (*RuntimeConfig) GetRulesFilterColumnsForSource added in v1.0.0

func (r *RuntimeConfig) GetRulesFilterColumnsForSource(src *Source, ruleType rule.Type) (rule.FilterAttrsType, bool)

GetRulesFilterColumnsForSource returns a set of all filter columns used in the rules of the given source.

The second return value indicates whether there are any rules without an object filter, in which case the events from the provided src should be processed nonetheless, even if they don't carry all the required filter columns unless it was explicitly requested to reject such events by the client.

func (*RuntimeConfig) GetSourceByClientCertSubject added in v1.0.0

func (r *RuntimeConfig) GetSourceByClientCertSubject(subject string) *Source

GetSourceByClientCertSubject returns a *Source by the given certificate subject.

func (*RuntimeConfig) GetSourceByUsername added in v1.0.0

func (r *RuntimeConfig) GetSourceByUsername(user string) *Source

GetSourceByUsername looks up a Source by its listener username without verifying a password.

This method is intended for connections over trusted transports such as Unix sockets, where the transport itself provides the security guarantee that no password is required.

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 {
	baseconf.IncrementalPkDbEntry[int64] `db:",inline"`

	Type string `db:"type"`
	Name string `db:"name"`

	ClientCertificateSubject types.String `db:"client_certificate_subject"`
	ListenerUsername         types.String `db:"listener_username"`
	ListenerPasswordHash     types.String `db:"listener_password_hash"`
	// contains filtered or unexported fields
}

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.

func (*Source) PasswordCompare added in v0.2.0

func (source *Source) PasswordCompare(password []byte) error

PasswordCompare checks if a password matches this Source's password with a cache.

This method returns nil if the password is correct, bcrypt.ErrMismatchedHashAndPassword in case of an invalid password and another error if something else went wrong.

This cache might be necessary as, for the moment, bcrypt is used to hash the passwords. By design, bcrypt is expensive, resulting in unnecessary delays when excessively using the API.

If either PHP's PASSWORD_DEFAULT changes or Icinga Web 2 starts using something else, e.g., Argon2id, this will return a descriptive error as the identifier does no longer match the bcrypt "$2y$".

If a Source changes, it will be recreated - RuntimeConfig.applyPendingSources has a nil updateFn - and the cache is automatically purged.

func (*Source) RuleIDs added in v1.0.0

func (source *Source) RuleIDs() iter.Seq[int64]

RuleIDs returns the list of rule IDs belonging to this source.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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