config: use configured reader by default (#1717)
This commit is contained in:
		
				
					committed by
					
						 Dominic Wong
						Dominic Wong
					
				
			
			
				
	
			
			
			
						parent
						
							81aa8e0231
						
					
				
				
					commit
					aef6878ee0
				
			| @@ -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 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user