bailout on incompatible duration format (#1326)

This commit is contained in:
Thibault "bui" Koechlin 2022-03-08 18:18:36 +01:00 committed by GitHub
parent 19817083d1
commit 5a15f9b39b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,6 +4,7 @@ import (
"fmt"
"io"
"os"
"time"
"github.com/antonmedv/expr"
"github.com/antonmedv/expr/vm"
@ -71,6 +72,13 @@ func (c *LocalApiServerCfg) LoadProfiles() error {
}
c.Profiles[pIdx].DebugFilters[fIdx] = debugFilter
}
for _, decision := range profile.Decisions {
if _, err := time.ParseDuration(*decision.Duration); err != nil {
return errors.Wrapf(err, "Error parsing duration '%s' of %s", *decision.Duration, profile.Name)
}
}
}
if len(c.Profiles) == 0 {
return fmt.Errorf("zero profiles loaded for LAPI")