add sanity check for metrics_reset_schedule

This commit is contained in:
ionutboangiu
2025-03-18 17:15:47 +02:00
committed by Dan Christian Bogos
parent ef4324fc0e
commit adadcd01cb

View File

@@ -27,6 +27,7 @@ import (
"strings"
"github.com/cgrates/cgrates/utils"
"github.com/cgrates/cron"
"github.com/cgrates/rpcclient"
)
@@ -914,6 +915,16 @@ func (cfg *CGRConfig) checkConfigSanity() error {
return fmt.Errorf("<%s> unsupported data type: %s for exporter with ID: %s", utils.EEs, exp.Type, exp.ID)
}
if exp.MetricsResetSchedule != "" {
parser := cron.NewParser(
cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow | cron.Descriptor,
)
if _, err := parser.Parse(exp.MetricsResetSchedule); err != nil {
return fmt.Errorf("<%s> invalid cron expression %q in metrics_reset_schedule for exporter %q: %v",
utils.EEs, exp.MetricsResetSchedule, exp.ID, err)
}
}
switch exp.Type {
case utils.MetaFileCSV:
for _, dir := range []string{exp.ExportPath} {