Use orgID when to function reports its write buckets. (#11363)
* Use orgID when to function reports its write buckets. fixes #11231pull/11413/head
parent
ba9e365aca
commit
c4e71bf412
|
@ -173,6 +173,12 @@ func (ToOpSpec) Kind() flux.OperationKind {
|
|||
// BucketsAccessed returns the buckets accessed by the spec.
|
||||
func (o *ToOpSpec) BucketsAccessed() (readBuckets, writeBuckets []platform.BucketFilter) {
|
||||
bf := platform.BucketFilter{Name: &o.Bucket, Organization: &o.Org}
|
||||
if o.OrgID != "" {
|
||||
id, err := platform.IDFromString(o.OrgID)
|
||||
if err == nil {
|
||||
bf.OrganizationID = id
|
||||
}
|
||||
}
|
||||
writeBuckets = append(writeBuckets, bf)
|
||||
return readBuckets, writeBuckets
|
||||
}
|
||||
|
|
|
@ -88,6 +88,7 @@ func TestToOpSpec_BucketsAccessed(t *testing.T) {
|
|||
t.Skip("https://github.com/influxdata/flux/issues/114")
|
||||
bucketName := "my_bucket"
|
||||
orgName := "my_org"
|
||||
id := platform.ID(1)
|
||||
tests := []querytest.BucketAwareQueryTestCase{
|
||||
{
|
||||
Name: "from() with bucket and to with org and bucket",
|
||||
|
@ -95,6 +96,12 @@ func TestToOpSpec_BucketsAccessed(t *testing.T) {
|
|||
WantReadBuckets: &[]platform.BucketFilter{{Name: &bucketName}},
|
||||
WantWriteBuckets: &[]platform.BucketFilter{{Name: &bucketName, Organization: &orgName}},
|
||||
},
|
||||
{
|
||||
Name: "from() with bucket and to with orgID and bucket",
|
||||
Raw: `from(bucket:"my_bucket") |> to(bucket:"my_bucket", orgID:"0000000000000001")`,
|
||||
WantReadBuckets: &[]platform.BucketFilter{{Name: &bucketName}},
|
||||
WantWriteBuckets: &[]platform.BucketFilter{{Name: &bucketName, OrganizationID: &id}},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
|
|
Loading…
Reference in New Issue