config

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2023 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ResetLocalEnviron

func ResetLocalEnviron()

Reset the environment used by checkEnv (primarily for testing).

Types

type AuthConfig added in v0.5.0

type AuthConfig struct {
	KeysURL            string        `split_words:"true" default:"https://auth.rotational.app/.well-known/jwks.json"`
	Audience           string        `default:"https://ensign.rotational.app"`
	Issuer             string        `default:"https://auth.rotational.app"`
	MinRefreshInterval time.Duration `split_words:"true" default:"5m"`
}

AuthConfig defines how Ensign connects to Quarterdeck in order to authorize requests.

func (AuthConfig) AuthOptions added in v0.5.0

func (c AuthConfig) AuthOptions() []middleware.AuthOption

type Config

type Config struct {
	Maintenance bool                `default:"false" yaml:"maintenance"`
	LogLevel    logger.LevelDecoder `split_words:"true" default:"info" yaml:"log_level"`
	ConsoleLog  bool                `split_words:"true" default:"false" yaml:"console_log"`
	BindAddr    string              `split_words:"true" default:":5356" yaml:"bind_addr"`
	Monitoring  MonitoringConfig
	Storage     StorageConfig
	Auth        AuthConfig
	Sentry      sentry.Config
	// contains filtered or unexported fields
}

Config contains all of the configuration parameters for an Ensign server and is loaded from the environment or a configuration file with reasonable defaults for values that are omitted. The Config should be validated in preparation for running the Ensign server to ensure that all server operations work as expected.

func Load

func Load(path string) (conf Config, err error)

Load and process a Config from the specified configuration file, then process the configuration from the environment. If the configuration is invalid or cannot be processed either from the file or the environment, then an error is returned. The configuration file is processed based on its file extension. YAML files with a .yaml or .yml extension are preferred, but JSON (.json) and TOML (.toml) files will also be processed. If the path has an unrecognized extension an error is returned. HACK: this is a beta function right now and is not fully tested; use with care!

func New

func New() (conf Config, err error)

New creates and processes a Config from the environment ready for use. If the configuration is invalid or it cannot be processed an error is returned.

func (Config) GetLogLevel

func (c Config) GetLogLevel() zerolog.Level

Parse and return the zerolog log level for configuring global logging.

func (Config) IsZero

func (c Config) IsZero() bool

A Config is zero-valued if it hasn't been processed by a file or the environment.

func (Config) Mark

func (c Config) Mark() (Config, error)

Mark a manually constructed config as processed as long as its valid.

func (Config) Path

func (c Config) Path() string

The path to the configuration file on disk when it was loaded. Returns empty string if the config was not loaded from a configuration file.

func (Config) Validate

func (c Config) Validate() (err error)

Validates the config is ready for use in the application and that configuration semantics such as requiring multiple required configuration parameters are enforced.

type MonitoringConfig

type MonitoringConfig struct {
	Enabled  bool   `default:"true" yaml:"enabled"`
	BindAddr string `split_words:"true" default:":1205" yaml:"bind_addr"`
	NodeID   string `split_words:"true" required:"false" yaml:"node"`
}

MonitoringConfig maintains the parameters for the o11y server that the Prometheus scraper will fetch the configured observability metrics from.

type StorageConfig added in v0.4.0

type StorageConfig struct {
	ReadOnly bool   `default:"false" split_words:"true" yaml:"read_only"`
	DataPath string `split_words:"true" yaml:"data_path"`
	Testing  bool   `default:"false" yaml:"testing"`
}

StorageConfig defines on disk where Ensign keeps its data. Users must specify the DataPath directory where Ensign will store it's data.

func (StorageConfig) EventPath added in v0.4.0

func (c StorageConfig) EventPath() (path string, err error)

EventPath returns the path to the event data store for Ensign, checking to make sure that the directory exists and that it is a directory. If it doesn't exist, the directory is created; an error is returned if the path is invalid or cannot be created.

func (StorageConfig) MetaPath added in v0.4.0

func (c StorageConfig) MetaPath() (path string, err error)

MetaPath returns the path to the metadata store for Ensign, checking to make sure that the directory exists and that it is a directory. If it doesn't exist, the directory is created; an error is returned if the path is invalid or cannot be created.

func (StorageConfig) Validate added in v0.4.0

func (c StorageConfig) Validate() (err error)

Jump to

Keyboard shortcuts

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