Documentation
¶
Index ¶
Constants ¶
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
GetConfigPath implements config.Flags.
func (Flags) IsExplicitConfigPath ¶ added in v1.0.0
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
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).
type Mode ¶ added in v1.0.0
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
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
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.