Documentation ¶
Overview ¶
Package loader provides reading configuration from streamable data
Package loader provides reading configuration from os environment
Index ¶
Constants ¶
const ( // EnvSource constant for environment variable source EnvSource = "env" // ArgsSource constant for command line args source ArgsSource = "args" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Data ¶
type Data struct { // Location is the address identifier from where the data will be read Location string // Reader creates a readable channel (io.Reader) from the provided location Reader Reader // Parser parses the data read from the channel to the database used by config.Provider Parser Parser }
Data reads uses the the Location, Reader and Parser to load an instance of config.Provider
type EqualDelimiterParser ¶
type EqualDelimiterParser struct { // Name identifier for the data that is being loaded Name string // Prefix to filter undesirable entries in slice Prefix string // Data to be parsed Data []string }
EqualDelimiterParser parses Data string slice to a config.Provider, considering only prefixed variables
func (*EqualDelimiterParser) Load ¶
func (p *EqualDelimiterParser) Load() (cfg config.Provider, err error)
Load config.Provider instance from the provided Data string slice and prefix
func (*EqualDelimiterParser) Source ¶
func (p *EqualDelimiterParser) Source() string
Source returns an identifier for this loader
type IOReadCloser ¶ added in v0.2.0
type IOReadCloser interface { io.ReadCloser }
IOReadCloser currently just wraps io.ReadCloser, allowing for mock generation when testing with io.ReadCloser
type IOReader ¶ added in v0.2.0
IOReader currently just wraps io.Reader, allowing for mock generation when testing with io.Reader
type Parser ¶
type Parser interface { // Parse provided data to to a key value store (map[string]interface{}) Parse(io.Reader) (map[string]interface{}, error) }
Parser interface with function to read data to a key value store
type Reader ¶
type Reader interface { // Read provides a channel to be read from the provided location. if io.Reader response is also a io.Closer, loader.Data will try to close it after parse Read(string) (io.Reader, error) }
Reader interface with function to provide the readable channel (io.ReadCloser).