fix(templates): allow same duration unit identifiers that the tasks api allows (#19710)
parent
d0338165e6
commit
e8931bbffa
|
@ -21,6 +21,7 @@ import (
|
|||
"github.com/influxdata/flux/parser"
|
||||
"github.com/influxdata/influxdb/v2"
|
||||
"github.com/influxdata/influxdb/v2/pkg/jsonnet"
|
||||
"github.com/influxdata/influxdb/v2/task/options"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
|
@ -1837,7 +1838,12 @@ func (r Resource) boolShort(key string) bool {
|
|||
}
|
||||
|
||||
func (r Resource) duration(key string) (time.Duration, bool) {
|
||||
dur, err := time.ParseDuration(r.stringShort(key))
|
||||
astDur, err := options.ParseSignedDuration(r.stringShort(key))
|
||||
if err != nil {
|
||||
return time.Duration(0), false
|
||||
}
|
||||
|
||||
dur, err := ast.DurationFrom(astDur, time.Time{})
|
||||
return dur, err == nil
|
||||
}
|
||||
|
||||
|
|
|
@ -3409,7 +3409,7 @@ spec:
|
|||
|
||||
task1 := tasks[1]
|
||||
baseEqual(t, 0, influxdb.Inactive, task1)
|
||||
assert.Equal(t, (10 * time.Minute).String(), task1.Every)
|
||||
assert.Equal(t, (25 * time.Hour).String(), task1.Every)
|
||||
assert.Equal(t, (15 * time.Second).String(), task1.Offset)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
"spec": {
|
||||
"name": "task-0",
|
||||
"description": "desc_0",
|
||||
"every": "10m",
|
||||
"every": "1d1h",
|
||||
"offset": "15s",
|
||||
"query": "from(bucket: \"rucket_1\")\n |> range(start: -5d, stop: -1h)\n |> filter(fn: (r) => r._measurement == \"cpu\")\n |> filter(fn: (r) => r._field == \"usage_idle\")\n |> aggregateWindow(every: 1m, fn: mean)\n |> yield(name: \"mean\")",
|
||||
"status": "inactive",
|
||||
|
|
|
@ -10,7 +10,7 @@ metadata:
|
|||
spec:
|
||||
name: task-0
|
||||
description: desc_0
|
||||
every: 10m
|
||||
every: 1d1h
|
||||
offset: 15s
|
||||
query: >
|
||||
from(bucket: "rucket_1")
|
||||
|
|
Loading…
Reference in New Issue