Documentation
¶
Overview ¶
Package config has specific primitives for loading application configurations.
Primitives:
- Application should have struct for containing configuration. E.g. refer propeller/internal/config/config.go file.
- Application should have a directory holding default file and environment specific file. E.g. refer propeller/configs/* directory.
Usage:
- E.g. NewDefaultConfig().Load("dev", &config), where config is a struct where configuration gets unmarshalled into.
Index ¶
Constants ¶
const ( DefaultConfigType = "toml" DefaultConfigDir = "./config" DefaultConfigFileName = "propeller" FilePath = "PROPELLER_CONFIG_FILE_PATH" )
Default options for configuration loading.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is a wrapper over a underlying config loader implementation.
func NewDefaultConfig ¶
func NewDefaultConfig() *Config
NewDefaultConfig returns new config struct with default options.
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options is config options.
func NewDefaultOptions ¶
func NewDefaultOptions() Options
NewDefaultOptions returns default options. DISCLAIMER: This function is a bit hacky This function expects an env $WORKDIR to be set and reads configs from $WORKDIR/configs. If $WORKDIR is not set. It uses the absolute path wrt the location of this file (config.go) to set configPath to 2 levels up in viper (../../configs). This function breaks if : 1. $WORKDIR is set and configs dir not present in $WORKDIR 2. $WORKDIR is not set and ../../configs is not present 3. $WORKDIR is not set and runtime absolute path of configs is different than build time path as runtime.Caller() evaluates only at build time