summaryrefslogtreecommitdiff
path: root/vendor/github.com/prometheus/common/model/time.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/prometheus/common/model/time.go')
-rw-r--r--vendor/github.com/prometheus/common/model/time.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/vendor/github.com/prometheus/common/model/time.go b/vendor/github.com/prometheus/common/model/time.go
index 7b0064fdb..490a0240c 100644
--- a/vendor/github.com/prometheus/common/model/time.go
+++ b/vendor/github.com/prometheus/common/model/time.go
@@ -186,6 +186,10 @@ var durationRE = regexp.MustCompile("^([0-9]+)(y|w|d|h|m|s|ms)$")
// ParseDuration parses a string into a time.Duration, assuming that a year
// always has 365d, a week always has 7d, and a day always has 24h.
func ParseDuration(durationStr string) (Duration, error) {
+ // Allow 0 without a unit.
+ if durationStr == "0" {
+ return 0, nil
+ }
matches := durationRE.FindStringSubmatch(durationStr)
if len(matches) != 3 {
return 0, fmt.Errorf("not a valid duration string: %q", durationStr)