From 7da6c78449776e1f3c6716250bca0b712a0423a4 Mon Sep 17 00:00:00 2001 From: Valery Piashchynski Date: Thu, 21 Jan 2021 13:25:36 +0300 Subject: Uniform all configs Add debug server Check nil's for all plugin intialization --- plugins/reload/plugin.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'plugins/reload/plugin.go') diff --git a/plugins/reload/plugin.go b/plugins/reload/plugin.go index 93760b8a..d76fb0a4 100644 --- a/plugins/reload/plugin.go +++ b/plugins/reload/plugin.go @@ -27,14 +27,18 @@ type Plugin struct { // Init controller service func (s *Plugin) Init(cfg config.Configurer, log logger.Logger, res resetter.Resetter) error { const op = errors.Op("reload_plugin_init") - s.cfg = &Config{} - InitDefaults(s.cfg) + if !cfg.Has(PluginName) { + return errors.E(op, errors.Disabled) + } + err := cfg.UnmarshalKey(PluginName, &s.cfg) if err != nil { // disable plugin in case of error return errors.E(op, errors.Disabled, err) } + s.cfg.InitDefaults() + s.log = log s.res = res s.stopc = make(chan struct{}, 1) @@ -101,7 +105,7 @@ func (s *Plugin) Serve() chan error { } }() - // map with configs by services + // map with config by services updated := make(map[string]ServiceConfig, len(s.cfg.Services)) go func() { -- cgit v1.2.3