Documentation ¶
Overview ¶
Package loader provides an easy way to load and merge configuration files and decode them into one single configuration struct.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConfigLoader ¶
type ConfigLoader struct {
// contains filtered or unexported fields
}
func NewConfigLoader ¶
func NewConfigLoader(opts ...OptFunc) *ConfigLoader
NewConfigLoader creates a new ConfigLoader instances with viper and `env` function pre-loaded.
func (*ConfigLoader) AppendConfig ¶
func (cl *ConfigLoader) AppendConfig(config, configType string) error
AppendConfig appends a plain string config (similar to a config file but in string), parses and merges it with current config.
func (*ConfigLoader) LoadConfigFiles ¶
func (cl *ConfigLoader) LoadConfigFiles(fileNames ...string) error
LoadConfigFiles loads and parses one or more config files. The latter files will merge with previous ones in order. Should be followed by Unmarshal to create a struct out of the config.
func (*ConfigLoader) Unmarshal ¶
func (cl *ConfigLoader) Unmarshal(v interface{}, opts ...viper.DecoderConfigOption) error
Unmarshal unmarshals current config into a struct.
func (*ConfigLoader) Viper ¶
func (cl *ConfigLoader) Viper() *viper.Viper
Viper returns the underlying viper instance.
type OptFunc ¶
type OptFunc func(*ConfigLoader)
func WithCustomTemplateFunc ¶
WithCustomTemplateFunc registers a custom function to use with the template, similar to `env` and `vault`.
func WithDelimiters ¶
WithDelimiters changes the default template delimiters {{ }}.
func WithVaultClient ¶
WithVaultClient enables vault function to fetch secrets from Hashicorp Vault. Example: {{ vault "secrets/path" "bar_key" "default_value" }}.