guard agains not fully configured config sources

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-12-20 01:00:45 +03:00
parent b50855855b
commit 6b1ed63b48
1 changed files with 9 additions and 1 deletions

View File

@ -41,7 +41,10 @@ func (s *service) Init(opts ...Option) error {
}
for _, cfg := range s.opts.Configs {
if cfg.Options().Struct == nil {
// skip config as the struct not passed
continue
}
if err := cfg.Init(config.Context(s.opts.Context)); err != nil {
return err
}
@ -161,6 +164,11 @@ func (s *service) Start() error {
}
for _, cfg := range s.opts.Configs {
if cfg.Options().Struct == nil {
// skip config as the struct not passed
continue
}
if err := cfg.Load(s.opts.Context); err != nil {
return err
}