[#1770] node: Validate config before apply it

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2022-09-30 17:13:16 +03:00 committed by fyrchik
parent 8ebe95747e
commit 1e35c12cc1

View file

@ -152,15 +152,22 @@ type subStorageCfg struct {
// not modifying them.
func (a *applicationConfiguration) readConfig(c *config.Config) error {
if a._read {
// clear if it is rereading
*a = applicationConfiguration{}
err := c.Reload()
if err != nil {
return err
return fmt.Errorf("could not reload configuration: %w", err)
}
err = validateConfig(c)
if err != nil {
return fmt.Errorf("configuration's validation: %w", err)
}
// clear if it is rereading
*a = applicationConfiguration{}
} else {
// update the status
// update the status.
// initial configuration validation is expected to be
// performed on the higher level
a._read = true
}