forked from oplehto/platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspec.go
More file actions
30 lines (25 loc) · 879 Bytes
/
spec.go
File metadata and controls
30 lines (25 loc) · 879 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package query
import (
"github.com/influxdata/flux"
"github.com/influxdata/platform"
)
// BucketAwareOperationSpec specifies an operation that reads or writes buckets
type BucketAwareOperationSpec interface {
BucketsAccessed() (readBuckets, writeBuckets []platform.BucketFilter)
}
// BucketsAccessed returns the set of buckets read and written by a query spec
func BucketsAccessed(q *flux.Spec) (readBuckets, writeBuckets []platform.BucketFilter, err error) {
err = q.Walk(func(o *flux.Operation) error {
bucketAwareOpSpec, ok := o.Spec.(BucketAwareOperationSpec)
if ok {
opBucketsRead, opBucketsWritten := bucketAwareOpSpec.BucketsAccessed()
readBuckets = append(readBuckets, opBucketsRead...)
writeBuckets = append(writeBuckets, opBucketsWritten...)
}
return nil
})
if err != nil {
return nil, nil, err
}
return readBuckets, writeBuckets, nil
}