Documentation ¶
Index ¶
- Variables
- type BytesLoader
- type Engine
- type FileLoader
- type Loader
- type Manager
- type MapEngine
- func (engine *MapEngine) GetBool(key string) (bool, error)
- func (engine *MapEngine) GetBoolSlice(key string) ([]bool, error)
- func (engine *MapEngine) GetDuration(key string) (time.Duration, error)
- func (engine *MapEngine) GetFloat(key string) (float64, error)
- func (engine *MapEngine) GetFloatSlice(key string) ([]float64, error)
- func (engine *MapEngine) GetInt(key string) (int, error)
- func (engine *MapEngine) GetInt64(key string) (int64, error)
- func (engine *MapEngine) GetInt64Slice(key string) ([]int64, error)
- func (engine *MapEngine) GetIntSlice(key string) ([]int, error)
- func (engine *MapEngine) GetString(key string) (string, error)
- func (engine *MapEngine) GetStringSlice(key string) ([]string, error)
- func (engine *MapEngine) GetUint(key string) (uint, error)
- func (engine *MapEngine) GetUint64(key string) (uint64, error)
- func (engine *MapEngine) GetUint64Slice(key string) ([]uint64, error)
- func (engine *MapEngine) GetUintSlice(key string) ([]uint, error)
- func (engine *MapEngine) Load() error
- func (engine *MapEngine) Unload() error
- type Option
- type Validator
- type YAMLEngine
Constants ¶
This section is empty.
Variables ¶
var ( // ErrKeyNotFound is returned when a key is not found by an engine. ErrKeyNotFound = errors.New("key not found") // ErrTypeMismatch is returned when a type mismatch for Engine get operations. ErrTypeMismatch = errors.New("type mismatch") // ErrNoSecretEngineDefined is returned by Manager.Populate when a secret config is defined but there is no secret // engine defined. ErrNoSecretEngineDefined = errors.New("no secret engine defined") // ErrNoPlainEngineDefined is returned by Manager.Populate when a plain config is defined but there is no plain // engine defined. ErrNoPlainEngineDefined = errors.New("no plain engine defined") // ErrEngineNotLoaded is returned when trying to get a key from an Engine that is not loaded. ErrEngineNotLoaded = errors.New("engine not loaded") // ErrConfigNotPointer is returned by Manager.Populate when the config is not a pointer. ErrConfigNotPointer = errors.New("config not pointer") )
Functions ¶
This section is empty.
Types ¶
type BytesLoader ¶
type BytesLoader struct {
// contains filtered or unexported fields
}
BytesLoader receives a byte slice and implements the Loader interface.
func NewBytesLoader ¶
func NewBytesLoader(bytes []byte) *BytesLoader
NewBytesLoader creates a new BytesLoader.
func (*BytesLoader) Load ¶
func (loader *BytesLoader) Load() (io.Reader, error)
Load returns a io.Reader from the given bytes (check NewBytesLoader).
func (*BytesLoader) Unload ¶
func (loader *BytesLoader) Unload() error
Unload sets the internal pointer to the given slice to nil.
type Engine ¶
type Engine interface { Load() error Unload() error GetString(key string) (string, error) GetStringSlice(key string) ([]string, error) GetInt(key string) (int, error) GetIntSlice(key string) ([]int, error) GetUint(key string) (uint, error) GetUintSlice(key string) ([]uint, error) GetInt64(key string) (int64, error) GetInt64Slice(key string) ([]int64, error) GetUint64(key string) (uint64, error) GetUint64Slice(key string) ([]uint64, error) GetBool(key string) (bool, error) GetBoolSlice(key string) ([]bool, error) GetFloat(key string) (float64, error) GetFloatSlice(key string) ([]float64, error) GetDuration(key string) (time.Duration, error) }
Engine is an interface that provides the contract for configuration engines to be able to read configuration from a variety of sources.
type FileLoader ¶
type FileLoader struct {
// contains filtered or unexported fields
}
FileLoader is a config loader that loads a file. This can be used to load JSON, YAML, or INI files, according with the Engine that is being used.
func NewFileLoader ¶
func NewFileLoader(filePath string) *FileLoader
func (*FileLoader) Load ¶
func (loader *FileLoader) Load() (io.Reader, error)
Load loads the given filePath (check NewFileLoader) saving the file handler for further use.
func (*FileLoader) Unload ¶
func (loader *FileLoader) Unload() error
Unload closes the file handler.
type Loader ¶
type Loader interface { // Load returns an io.Reader for reading the data to be unmarshaled by the // Engine implementation. Load() (io.Reader, error) // Unload is called when the configuration is no longer needed and all the // resources should be released. Unload() error }
Loader is the interface for loading configuration from a source.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func (*Manager) AddPlainEngine ¶
func (*Manager) AddSecretEngine ¶
type MapEngine ¶
type MapEngine struct {
// contains filtered or unexported fields
}
func NewMapEngine ¶
NewMapEngine returns a new instance of MapEngine with the given data.
Internally, it will flatten the data map before storing for future use.
func (*MapEngine) GetDuration ¶
func (*MapEngine) GetFloatSlice ¶
func (*MapEngine) GetInt64Slice ¶
func (*MapEngine) GetStringSlice ¶
func (*MapEngine) GetUint64Slice ¶
type Option ¶
type Option func(*Manager)
func WithKeySeparator ¶
WithKeySeparator sets the key separator for the manager.
type YAMLEngine ¶
type YAMLEngine struct { *MapEngine // contains filtered or unexported fields }
func NewYAMLEngine ¶
func NewYAMLEngine(loader Loader) *YAMLEngine
func (*YAMLEngine) Load ¶
func (engine *YAMLEngine) Load() error
Load loads the YAML file defined by the filePath set on the NewYAMLEngine saving the data into a internal map.