config: use configured reader by default (#1717)

This commit is contained in:
Colin Hoglund 2020-06-19 03:49:30 -04:00 committed by GitHub
parent 8c7c27c573
commit 83cecdb294
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -41,7 +41,6 @@ func newConfig(opts ...Option) (Config, error) {
func (c *config) Init(opts ...Option) error {
c.opts = Options{
Loader: memory.NewLoader(),
Reader: json.NewReader(),
}
c.exit = make(chan bool)
@ -49,6 +48,11 @@ func (c *config) Init(opts ...Option) error {
o(&c.opts)
}
// default loader uses the configured reader
if c.opts.Loader == nil {
c.opts.Loader = memory.NewLoader(memory.WithReader(c.opts.Reader))
}
err := c.opts.Loader.Load(c.opts.Source...)
if err != nil {
return err