config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2022 License: GPL-2.0 Imports: 30 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 Config

type Config struct {
	Database  Database  `yaml:"database"`
	Redis     Redis     `yaml:"redis"`
	Logging   Logging   `yaml:"logging"`
	Retention Retention `yaml:"retention"`
}

Config defines Icinga DB config.

func FromYAMLFile

func FromYAMLFile(name string) (*Config, error)

FromYAMLFile returns a new Config value created from the given YAML config file.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks constraints in the supplied configuration and returns an error if they are violated.

type Database

type Database struct {
	Type       string           `yaml:"type" default:"mysql"`
	Host       string           `yaml:"host"`
	Port       int              `yaml:"port"`
	Database   string           `yaml:"database"`
	User       string           `yaml:"user"`
	Password   string           `yaml:"password"`
	TlsOptions TLS              `yaml:",inline"`
	Options    icingadb.Options `yaml:"options"`
}

Database defines database client configuration.

func (*Database) Open

func (d *Database) Open(logger *logging.Logger) (*icingadb.DB, error)

Open prepares the DSN string and driver configuration, calls sqlx.Open, but returns *icingadb.DB.

func (*Database) Validate

func (d *Database) Validate() error

Validate checks constraints in the supplied database configuration and returns an error if they are violated.

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" required:"true" default:"/etc/icingadb/config.yml"`
}

Flags defines CLI flags.

func ParseFlags

func ParseFlags() (*Flags, error)

ParseFlags parses CLI flags and returns a Flags value created from them.

type Logging

type Logging struct {
	// zapcore.Level at 0 is for info level.
	Level  zapcore.Level `yaml:"level" default:"0"`
	Output string        `yaml:"output"`
	// Interval for periodic logging.
	Interval time.Duration `yaml:"interval" default:"20s"`

	logging.Options `yaml:"options"`
}

Logging defines Logger configuration.

func (*Logging) Validate

func (l *Logging) Validate() error

Validate checks constraints in the supplied Logging configuration and returns an error if they are violated. Also configures the log output if it is not configured: systemd-journald is used when Icinga DB is running under systemd, otherwise stderr.

type Redis

type Redis struct {
	Host       string              `yaml:"host"`
	Port       int                 `yaml:"port" default:"6380"`
	Password   string              `yaml:"password"`
	TlsOptions TLS                 `yaml:",inline"`
	Options    icingaredis.Options `yaml:"options"`
}

Redis defines Redis client configuration.

func (*Redis) NewClient

func (r *Redis) NewClient(logger *logging.Logger) (*icingaredis.Client, error)

NewClient prepares Redis client configuration, calls redis.NewClient, but returns *icingaredis.Client.

func (*Redis) Validate

func (r *Redis) Validate() error

Validate checks constraints in the supplied Redis configuration and returns an error if they are violated.

type Retention

type Retention struct {
	HistoryDays uint64                   `yaml:"history-days"`
	SlaDays     uint64                   `yaml:"sla-days"`
	Interval    time.Duration            `yaml:"interval" default:"1h"`
	Count       uint64                   `yaml:"count" default:"5000"`
	Options     history.RetentionOptions `yaml:"options"`
}

Retention defines configuration for history retention.

func (*Retention) Validate

func (r *Retention) Validate() error

Validate checks constraints in the supplied retention configuration and returns an error if they are violated.

type TLS

type TLS struct {
	Enable   bool   `yaml:"tls"`
	Cert     string `yaml:"cert"`
	Key      string `yaml:"key"`
	Ca       string `yaml:"ca"`
	Insecure bool   `yaml:"insecure"`
}

TLS provides TLS configuration options for Redis and Database.

func (*TLS) MakeConfig

func (t *TLS) MakeConfig(serverName string) (*tls.Config, error)

MakeConfig assembles a tls.Config from t and serverName.

Jump to

Keyboard shortcuts

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