mirror of
https://github.com/containrrr/watchtower.git
synced 2025-09-22 05:40:50 +02:00

- removes unwieldy SkipUpdate return value in favor of errors.Is - generalizes the code for all four phases - allows timeout to be defined for all phases - enables explicit unit in timeout label values (in addition to implicit minutes)
15 lines
398 B
Go
15 lines
398 B
Go
package util
|
|
|
|
import (
|
|
"strconv"
|
|
"time"
|
|
)
|
|
|
|
// ParseDuration parses the input string as a duration, treating a plain number as implicitly using the specified unit
|
|
func ParseDuration(input string, unitlessUnit time.Duration) (time.Duration, error) {
|
|
if unitless, err := strconv.Atoi(input); err == nil {
|
|
return unitlessUnit * time.Duration(unitless), nil
|
|
}
|
|
|
|
return time.ParseDuration(input)
|
|
}
|