New creates a new config module. It contains the init command.
(p ConfigIn)
| 35 | |
| 36 | // New creates a new config module. It contains the init command. |
| 37 | func New(p ConfigIn) (Module, error) { |
| 38 | var ( |
| 39 | ok bool |
| 40 | adapter *KoanfAdapter |
| 41 | ) |
| 42 | if adapter, ok = p.Conf.(*KoanfAdapter); !ok { |
| 43 | return Module{}, fmt.Errorf("expects a *config.KoanfAdapter instance, but %T given", p.Conf) |
| 44 | } |
| 45 | |
| 46 | if err := loadValidators(adapter, p.ExportedConfigs); err != nil { |
| 47 | return Module{}, err |
| 48 | } |
| 49 | |
| 50 | return Module{ |
| 51 | dispatcher: p.Dispatcher, |
| 52 | conf: adapter, |
| 53 | exportedConfigs: p.ExportedConfigs, |
| 54 | }, nil |
| 55 | } |
| 56 | |
| 57 | // ProvideRunGroup runs the configuration watcher. |
| 58 | func (m Module) ProvideRunGroup(group *run.Group) { |