config: use configured reader by default (#1717)
This commit is contained in:
parent
8c7c27c573
commit
83cecdb294
@ -41,7 +41,6 @@ func newConfig(opts ...Option) (Config, error) {
|
|||||||
|
|
||||||
func (c *config) Init(opts ...Option) error {
|
func (c *config) Init(opts ...Option) error {
|
||||||
c.opts = Options{
|
c.opts = Options{
|
||||||
Loader: memory.NewLoader(),
|
|
||||||
Reader: json.NewReader(),
|
Reader: json.NewReader(),
|
||||||
}
|
}
|
||||||
c.exit = make(chan bool)
|
c.exit = make(chan bool)
|
||||||
@ -49,6 +48,11 @@ func (c *config) Init(opts ...Option) error {
|
|||||||
o(&c.opts)
|
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...)
|
err := c.opts.Loader.Load(c.opts.Source...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user