Config: Interpret empty duration strings as duration = 0.

In practice, we allowed this already, because parsing failed
but Validate() succeeded.

License: MIT
Signed-off-by: Hector Sanjuan <code@hector.link>
This commit is contained in:
Hector Sanjuan 2019-01-11 19:29:56 +01:00
parent 5075504926
commit e891c33e40

View File

@ -96,6 +96,10 @@ type DurationOpt struct {
// ParseDurations takes a time.Duration src and saves it to the given dst.
func ParseDurations(component string, args ...*DurationOpt) error {
for _, arg := range args {
if arg.Duration == "" {
*arg.Dst = 0
continue
}
t, err := time.ParseDuration(arg.Duration)
if err != nil {
return fmt.Errorf(