daemon

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: 15 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

View Source
const (
	ExitSuccess = 0
	ExitFailure = 1
)

Variables

This section is empty.

Functions

func InjectTestConfig added in v1.0.0

func InjectTestConfig(f func(*ConfigFile))

InjectTestConfig allows tests to modify the daemon configuration before it is used.

The provided function f is called with a pointer to the ConfigFile, allowing tests to set specific values. It's safe for concurrent tests, and only the first call to InjectTestConfig will have an effect and any subsequent calls will be ignored.

Types

type ConfigFile

type ConfigFile struct {
	ChannelsDir string          `yaml:"channels_dir" env:"CHANNELS_DIR"`
	Listener    Listener        `yaml:"listener" envPrefix:"LISTENER_"`
	Database    database.Config `yaml:"database" envPrefix:"DATABASE_"`
	Retention   Retention       `yaml:"retention" envPrefix:"RETENTION_"`
	Logging     logging.Config  `yaml:"logging" envPrefix:"LOGGING_"`
}

func Config

func Config() *ConfigFile

Config returns the config that was loaded while starting the daemon. Panics when ParseFlagsAndConfig was not called earlier.

func (*ConfigFile) SetDefaults

func (c *ConfigFile) SetDefaults()

SetDefaults implements the defaults.Setter interface.

func (*ConfigFile) Validate

func (c *ConfigFile) Validate() error

Validate implements the config.Validator interface. Validates the entire daemon configuration on daemon startup.

type Flags

type Flags struct {
	// Version decides whether to just print the version and exit.
	Version bool `long:"version" description:"print version and exit"`
	// Config is the path to the config file
	Config string `short:"c" long:"config" description:"path to config file"`

	// DatabaseAutoImport imports the initial database schema on startup if none exists; mostly for containerized setups.
	DatabaseAutoImport bool `long:"database-auto-import" description:"import database schema on startup if none exists"`

	// DatabaseSchemaDir is the root directory for schema files to be used when DatabaseAutoImport is requested.
	//
	// The directory structure must mimic the git repo's schema dir, containing ./mysql/schema.sql and ./pgsql/schema.sql.
	DatabaseSchemaDir string `` /* 166-byte string literal not displayed */

	// DBSchemaOnly makes the daemon exit successfully right after it has verified that the database schema exists,
	// without starting any other components.
	//
	// It is only meaningful in combination with the other schema related flags, i.e., --database-auto-import and
	// optionally --database-schema-dir, to perform a one-shot schema import (e.g., in an init container or CI).
	//
	// Without --database-auto-import, it merely checks for the schema and exits with an error if it is missing.
	DBSchemaOnly bool `` /* 150-byte string literal not displayed */
}

Flags defines the CLI flags supported by Icinga Notifications.

func ParseFlagsAndConfig

func ParseFlagsAndConfig() *Flags

ParseFlagsAndConfig parses the CLI flags provided to the executable and tries to load the config from the YAML file.

On success, it returns a pointer to the parsed Flags struct.

Prints any error during parsing or config loading to os.Stderr and exits.

func (Flags) GetConfigPath added in v1.0.0

func (f Flags) GetConfigPath() string

GetConfigPath implements config.Flags.

func (Flags) IsExplicitConfigPath added in v1.0.0

func (f Flags) IsExplicitConfigPath() bool

IsExplicitConfigPath implements config.Flags.

type Listener added in v1.0.0

type Listener struct {
	Addr              string           `yaml:"address" env:"ADDRESS"`
	Socket            string           `yaml:"socket" env:"SOCKET"`
	SocketMode        *Mode            `yaml:"socket_mode" env:"SOCKET_MODE" default:"0660"`
	SocketGroup       string           `yaml:"socket_group" env:"SOCKET_GROUP"`
	DebugPassword     string           `yaml:"debug_password" env:"DEBUG_PASSWORD"`
	DebugPasswordFile string           `yaml:"debug_password_file" env:"DEBUG_PASSWORD_FILE"`
	TLSOptions        config.TLSCommon `yaml:",inline"`
	CrlFile           string           `yaml:"crl_file" env:"CRL_FILE"`
}

Listener defines the configuration for the Icinga Notifications API listener.

func (*Listener) GetTlsConfig added in v1.0.0

func (l *Listener) GetTlsConfig() (*tls.Config, *config.CrlChecker, bool, error)

GetTlsConfig returns a *tls.Config and a *config.CrlChecker based on the TLS options specified in the Listener configuration. The boolean return value indicates whether revocation checking is enabled (true) or not (false).

func (*Listener) Validate added in v1.0.0

func (l *Listener) Validate() error

type Mode added in v1.0.0

type Mode fs.FileMode

Mode is a Unix file permission mode parsed from an octal string in YAML or environment configuration.

func (*Mode) UnmarshalText added in v1.0.0

func (m *Mode) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler for Mode, parsing an octal string (e.g. "0660") into a file mode.

type Retention added in v1.0.0

type Retention struct {
	Period    time.Duration `yaml:"period" env:"PERIOD"`
	Interval  time.Duration `yaml:"interval" env:"INTERVAL" default:"1h"`
	BatchSize uint64        `yaml:"batch_size" env:"BATCH_SIZE" default:"5000"`
	Options   RetentionOpts `yaml:"options" envPrefix:"OPTIONS_"`
}

Retention defines the retention policy for Icinga Notifications history cleanups.

func (*Retention) Validate added in v1.0.0

func (r *Retention) Validate() error

Validate implements the config.Validator interface.

type RetentionOpts added in v1.0.0

type RetentionOpts struct {
	Incident            *time.Duration `yaml:"incident" env:"INCIDENT"`
	NotificationHistory *time.Duration `yaml:"notification_history" env:"NOTIFICATION_HISTORY"`
}

RetentionOpts defines additional overrides for retention periods of specific components.

The fields here must be pointers to distinguish between "not set" and "set to zero" (i.e. no retention) when overriding the default retention period.

func (*RetentionOpts) Validate added in v1.0.0

func (r *RetentionOpts) Validate() error

Validate implements the config.Validator interface.

Jump to

Keyboard shortcuts

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