remove org from bucket
parent
3868149a6c
commit
7a72c363f2
|
@ -65,7 +65,7 @@ func (s *BucketService) FindBucketByID(ctx context.Context, id influxdb.ID) (*in
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := authorizeReadBucket(ctx, b.OrganizationID, id); err != nil {
|
if err := authorizeReadBucket(ctx, b.OrgID, id); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ func (s *BucketService) FindBucket(ctx context.Context, filter influxdb.BucketFi
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := authorizeReadBucket(ctx, b.OrganizationID, b.ID); err != nil {
|
if err := authorizeReadBucket(ctx, b.OrgID, b.ID); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ func (s *BucketService) FindBuckets(ctx context.Context, filter influxdb.BucketF
|
||||||
// https://github.com/golang/go/wiki/SliceTricks#filtering-without-allocating
|
// https://github.com/golang/go/wiki/SliceTricks#filtering-without-allocating
|
||||||
buckets := bs[:0]
|
buckets := bs[:0]
|
||||||
for _, b := range bs {
|
for _, b := range bs {
|
||||||
err := authorizeReadBucket(ctx, b.OrganizationID, b.ID)
|
err := authorizeReadBucket(ctx, b.OrgID, b.ID)
|
||||||
if err != nil && influxdb.ErrorCode(err) != influxdb.EUnauthorized {
|
if err != nil && influxdb.ErrorCode(err) != influxdb.EUnauthorized {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ func (s *BucketService) CreateBucket(ctx context.Context, b *influxdb.Bucket) er
|
||||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
span, ctx := tracing.StartSpanFromContext(ctx)
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
|
|
||||||
p, err := influxdb.NewPermission(influxdb.WriteAction, influxdb.BucketsResourceType, b.OrganizationID)
|
p, err := influxdb.NewPermission(influxdb.WriteAction, influxdb.BucketsResourceType, b.OrgID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ func (s *BucketService) UpdateBucket(ctx context.Context, id influxdb.ID, upd in
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := authorizeWriteBucket(ctx, b.OrganizationID, id); err != nil {
|
if err := authorizeWriteBucket(ctx, b.OrgID, id); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ func (s *BucketService) DeleteBucket(ctx context.Context, id influxdb.ID) error
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := authorizeWriteBucket(ctx, b.OrganizationID, id); err != nil {
|
if err := authorizeWriteBucket(ctx, b.OrgID, id); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ func TestBucketService_FindBucketByID(t *testing.T) {
|
||||||
FindBucketByIDFn: func(ctx context.Context, id influxdb.ID) (*influxdb.Bucket, error) {
|
FindBucketByIDFn: func(ctx context.Context, id influxdb.ID) (*influxdb.Bucket, error) {
|
||||||
return &influxdb.Bucket{
|
return &influxdb.Bucket{
|
||||||
ID: id,
|
ID: id,
|
||||||
OrganizationID: 10,
|
OrgID: 10,
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -78,7 +78,7 @@ func TestBucketService_FindBucketByID(t *testing.T) {
|
||||||
FindBucketByIDFn: func(ctx context.Context, id influxdb.ID) (*influxdb.Bucket, error) {
|
FindBucketByIDFn: func(ctx context.Context, id influxdb.ID) (*influxdb.Bucket, error) {
|
||||||
return &influxdb.Bucket{
|
return &influxdb.Bucket{
|
||||||
ID: id,
|
ID: id,
|
||||||
OrganizationID: 10,
|
OrgID: 10,
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -139,7 +139,7 @@ func TestBucketService_FindBucket(t *testing.T) {
|
||||||
FindBucketFn: func(ctx context.Context, filter influxdb.BucketFilter) (*influxdb.Bucket, error) {
|
FindBucketFn: func(ctx context.Context, filter influxdb.BucketFilter) (*influxdb.Bucket, error) {
|
||||||
return &influxdb.Bucket{
|
return &influxdb.Bucket{
|
||||||
ID: 1,
|
ID: 1,
|
||||||
OrganizationID: 10,
|
OrgID: 10,
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -164,7 +164,7 @@ func TestBucketService_FindBucket(t *testing.T) {
|
||||||
FindBucketFn: func(ctx context.Context, filter influxdb.BucketFilter) (*influxdb.Bucket, error) {
|
FindBucketFn: func(ctx context.Context, filter influxdb.BucketFilter) (*influxdb.Bucket, error) {
|
||||||
return &influxdb.Bucket{
|
return &influxdb.Bucket{
|
||||||
ID: 1,
|
ID: 1,
|
||||||
OrganizationID: 10,
|
OrgID: 10,
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -226,15 +226,15 @@ func TestBucketService_FindBuckets(t *testing.T) {
|
||||||
return []*influxdb.Bucket{
|
return []*influxdb.Bucket{
|
||||||
{
|
{
|
||||||
ID: 1,
|
ID: 1,
|
||||||
OrganizationID: 10,
|
OrgID: 10,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: 2,
|
ID: 2,
|
||||||
OrganizationID: 10,
|
OrgID: 10,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: 3,
|
ID: 3,
|
||||||
OrganizationID: 11,
|
OrgID: 11,
|
||||||
},
|
},
|
||||||
}, 3, nil
|
}, 3, nil
|
||||||
},
|
},
|
||||||
|
@ -252,15 +252,15 @@ func TestBucketService_FindBuckets(t *testing.T) {
|
||||||
buckets: []*influxdb.Bucket{
|
buckets: []*influxdb.Bucket{
|
||||||
{
|
{
|
||||||
ID: 1,
|
ID: 1,
|
||||||
OrganizationID: 10,
|
OrgID: 10,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: 2,
|
ID: 2,
|
||||||
OrganizationID: 10,
|
OrgID: 10,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: 3,
|
ID: 3,
|
||||||
OrganizationID: 11,
|
OrgID: 11,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -274,15 +274,15 @@ func TestBucketService_FindBuckets(t *testing.T) {
|
||||||
return []*influxdb.Bucket{
|
return []*influxdb.Bucket{
|
||||||
{
|
{
|
||||||
ID: 1,
|
ID: 1,
|
||||||
OrganizationID: 10,
|
OrgID: 10,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: 2,
|
ID: 2,
|
||||||
OrganizationID: 10,
|
OrgID: 10,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: 3,
|
ID: 3,
|
||||||
OrganizationID: 11,
|
OrgID: 11,
|
||||||
},
|
},
|
||||||
}, 3, nil
|
}, 3, nil
|
||||||
},
|
},
|
||||||
|
@ -301,11 +301,11 @@ func TestBucketService_FindBuckets(t *testing.T) {
|
||||||
buckets: []*influxdb.Bucket{
|
buckets: []*influxdb.Bucket{
|
||||||
{
|
{
|
||||||
ID: 1,
|
ID: 1,
|
||||||
OrganizationID: 10,
|
OrgID: 10,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: 2,
|
ID: 2,
|
||||||
OrganizationID: 10,
|
OrgID: 10,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -354,13 +354,13 @@ func TestBucketService_UpdateBucket(t *testing.T) {
|
||||||
FindBucketByIDFn: func(ctc context.Context, id influxdb.ID) (*influxdb.Bucket, error) {
|
FindBucketByIDFn: func(ctc context.Context, id influxdb.ID) (*influxdb.Bucket, error) {
|
||||||
return &influxdb.Bucket{
|
return &influxdb.Bucket{
|
||||||
ID: 1,
|
ID: 1,
|
||||||
OrganizationID: 10,
|
OrgID: 10,
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
UpdateBucketFn: func(ctx context.Context, id influxdb.ID, upd influxdb.BucketUpdate) (*influxdb.Bucket, error) {
|
UpdateBucketFn: func(ctx context.Context, id influxdb.ID, upd influxdb.BucketUpdate) (*influxdb.Bucket, error) {
|
||||||
return &influxdb.Bucket{
|
return &influxdb.Bucket{
|
||||||
ID: 1,
|
ID: 1,
|
||||||
OrganizationID: 10,
|
OrgID: 10,
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -395,13 +395,13 @@ func TestBucketService_UpdateBucket(t *testing.T) {
|
||||||
FindBucketByIDFn: func(ctc context.Context, id influxdb.ID) (*influxdb.Bucket, error) {
|
FindBucketByIDFn: func(ctc context.Context, id influxdb.ID) (*influxdb.Bucket, error) {
|
||||||
return &influxdb.Bucket{
|
return &influxdb.Bucket{
|
||||||
ID: 1,
|
ID: 1,
|
||||||
OrganizationID: 10,
|
OrgID: 10,
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
UpdateBucketFn: func(ctx context.Context, id influxdb.ID, upd influxdb.BucketUpdate) (*influxdb.Bucket, error) {
|
UpdateBucketFn: func(ctx context.Context, id influxdb.ID, upd influxdb.BucketUpdate) (*influxdb.Bucket, error) {
|
||||||
return &influxdb.Bucket{
|
return &influxdb.Bucket{
|
||||||
ID: 1,
|
ID: 1,
|
||||||
OrganizationID: 10,
|
OrgID: 10,
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -465,7 +465,7 @@ func TestBucketService_DeleteBucket(t *testing.T) {
|
||||||
FindBucketByIDFn: func(ctc context.Context, id influxdb.ID) (*influxdb.Bucket, error) {
|
FindBucketByIDFn: func(ctc context.Context, id influxdb.ID) (*influxdb.Bucket, error) {
|
||||||
return &influxdb.Bucket{
|
return &influxdb.Bucket{
|
||||||
ID: 1,
|
ID: 1,
|
||||||
OrganizationID: 10,
|
OrgID: 10,
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
DeleteBucketFn: func(ctx context.Context, id influxdb.ID) error {
|
DeleteBucketFn: func(ctx context.Context, id influxdb.ID) error {
|
||||||
|
@ -503,7 +503,7 @@ func TestBucketService_DeleteBucket(t *testing.T) {
|
||||||
FindBucketByIDFn: func(ctc context.Context, id influxdb.ID) (*influxdb.Bucket, error) {
|
FindBucketByIDFn: func(ctc context.Context, id influxdb.ID) (*influxdb.Bucket, error) {
|
||||||
return &influxdb.Bucket{
|
return &influxdb.Bucket{
|
||||||
ID: 1,
|
ID: 1,
|
||||||
OrganizationID: 10,
|
OrgID: 10,
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
DeleteBucketFn: func(ctx context.Context, id influxdb.ID) error {
|
DeleteBucketFn: func(ctx context.Context, id influxdb.ID) error {
|
||||||
|
@ -621,7 +621,7 @@ func TestBucketService_CreateBucket(t *testing.T) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
ctx = influxdbcontext.SetAuthorizer(ctx, &Authorizer{[]influxdb.Permission{tt.args.permission}})
|
ctx = influxdbcontext.SetAuthorizer(ctx, &Authorizer{[]influxdb.Permission{tt.args.permission}})
|
||||||
|
|
||||||
err := s.CreateBucket(ctx, &influxdb.Bucket{OrganizationID: tt.args.orgID})
|
err := s.CreateBucket(ctx, &influxdb.Bucket{OrgID: tt.args.orgID})
|
||||||
influxdbtesting.ErrorsEqual(t, err, tt.wants.err)
|
influxdbtesting.ErrorsEqual(t, err, tt.wants.err)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,20 +30,6 @@ func (c *Client) initializeBuckets(ctx context.Context, tx *bolt.Tx) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) setOrganizationOnBucket(ctx context.Context, tx *bolt.Tx, b *platform.Bucket) *platform.Error {
|
|
||||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
|
||||||
defer span.Finish()
|
|
||||||
|
|
||||||
o, err := c.findOrganizationByID(ctx, tx, b.OrganizationID)
|
|
||||||
if err != nil {
|
|
||||||
return &platform.Error{
|
|
||||||
Err: err,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
b.Org = o.Name
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// FindBucketByID retrieves a bucket by id.
|
// FindBucketByID retrieves a bucket by id.
|
||||||
func (c *Client) FindBucketByID(ctx context.Context, id platform.ID) (*platform.Bucket, error) {
|
func (c *Client) FindBucketByID(ctx context.Context, id platform.ID) (*platform.Bucket, error) {
|
||||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
span, ctx := tracing.StartSpanFromContext(ctx)
|
||||||
|
@ -71,7 +57,7 @@ func (c *Client) FindBucketByID(ctx context.Context, id platform.ID) (*platform.
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) findBucketByID(ctx context.Context, tx *bolt.Tx, id platform.ID) (*platform.Bucket, *platform.Error) {
|
func (c *Client) findBucketByID(ctx context.Context, tx *bolt.Tx, id platform.ID) (*platform.Bucket, *platform.Error) {
|
||||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
span, _ := tracing.StartSpanFromContext(ctx)
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
|
|
||||||
var b platform.Bucket
|
var b platform.Bucket
|
||||||
|
@ -97,13 +83,6 @@ func (c *Client) findBucketByID(ctx context.Context, tx *bolt.Tx, id platform.ID
|
||||||
Err: err,
|
Err: err,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.setOrganizationOnBucket(ctx, tx, &b); err != nil {
|
|
||||||
return nil, &platform.Error{
|
|
||||||
Err: err,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return &b, nil
|
return &b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +114,7 @@ func (c *Client) findBucketByName(ctx context.Context, tx *bolt.Tx, orgID platfo
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
|
|
||||||
b := &platform.Bucket{
|
b := &platform.Bucket{
|
||||||
OrganizationID: orgID,
|
OrgID: orgID,
|
||||||
Name: n,
|
Name: n,
|
||||||
}
|
}
|
||||||
key, err := bucketIndexKey(b)
|
key, err := bucketIndexKey(b)
|
||||||
|
@ -233,7 +212,7 @@ func filterBucketsFn(filter platform.BucketFilter) func(b *platform.Bucket) bool
|
||||||
|
|
||||||
if filter.Name != nil && filter.OrganizationID != nil {
|
if filter.Name != nil && filter.OrganizationID != nil {
|
||||||
return func(b *platform.Bucket) bool {
|
return func(b *platform.Bucket) bool {
|
||||||
return b.Name == *filter.Name && b.OrganizationID == *filter.OrganizationID
|
return b.Name == *filter.Name && b.OrgID == *filter.OrganizationID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,7 +224,7 @@ func filterBucketsFn(filter platform.BucketFilter) func(b *platform.Bucket) bool
|
||||||
|
|
||||||
if filter.OrganizationID != nil {
|
if filter.OrganizationID != nil {
|
||||||
return func(b *platform.Bucket) bool {
|
return func(b *platform.Bucket) bool {
|
||||||
return b.OrganizationID == *filter.OrganizationID
|
return b.OrgID == *filter.OrganizationID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,23 +329,14 @@ func (c *Client) CreateBucket(ctx context.Context, b *platform.Bucket) error {
|
||||||
var err error
|
var err error
|
||||||
op := getOp(platform.OpCreateBucket)
|
op := getOp(platform.OpCreateBucket)
|
||||||
return c.db.Update(func(tx *bolt.Tx) error {
|
return c.db.Update(func(tx *bolt.Tx) error {
|
||||||
if b.OrganizationID.Valid() {
|
if b.OrgID.Valid() {
|
||||||
_, pe := c.findOrganizationByID(ctx, tx, b.OrganizationID)
|
_, pe := c.findOrganizationByID(ctx, tx, b.OrgID)
|
||||||
if pe != nil {
|
if pe != nil {
|
||||||
return &platform.Error{
|
return &platform.Error{
|
||||||
Err: pe,
|
Err: pe,
|
||||||
Op: op,
|
Op: op,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
o, pe := c.findOrganizationByName(ctx, tx, b.Org)
|
|
||||||
if pe != nil {
|
|
||||||
return &platform.Error{
|
|
||||||
Err: pe,
|
|
||||||
Op: op,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
b.OrganizationID = o.ID
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unique := c.uniqueBucketName(ctx, tx, b)
|
unique := c.uniqueBucketName(ctx, tx, b)
|
||||||
|
@ -417,7 +387,7 @@ func (c *Client) PutBucket(ctx context.Context, b *platform.Bucket) error {
|
||||||
func (c *Client) createBucketUserResourceMappings(ctx context.Context, tx *bolt.Tx, b *platform.Bucket) *platform.Error {
|
func (c *Client) createBucketUserResourceMappings(ctx context.Context, tx *bolt.Tx, b *platform.Bucket) *platform.Error {
|
||||||
ms, err := c.findUserResourceMappings(ctx, tx, platform.UserResourceMappingFilter{
|
ms, err := c.findUserResourceMappings(ctx, tx, platform.UserResourceMappingFilter{
|
||||||
ResourceType: platform.OrgsResourceType,
|
ResourceType: platform.OrgsResourceType,
|
||||||
ResourceID: b.OrganizationID,
|
ResourceID: b.OrgID,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &platform.Error{
|
return &platform.Error{
|
||||||
|
@ -442,7 +412,6 @@ func (c *Client) createBucketUserResourceMappings(ctx context.Context, tx *bolt.
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) putBucket(ctx context.Context, tx *bolt.Tx, b *platform.Bucket) *platform.Error {
|
func (c *Client) putBucket(ctx context.Context, tx *bolt.Tx, b *platform.Bucket) *platform.Error {
|
||||||
b.Org = ""
|
|
||||||
v, err := json.Marshal(b)
|
v, err := json.Marshal(b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &platform.Error{
|
return &platform.Error{
|
||||||
|
@ -471,11 +440,11 @@ func (c *Client) putBucket(ctx context.Context, tx *bolt.Tx, b *platform.Bucket)
|
||||||
Err: err,
|
Err: err,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return c.setOrganizationOnBucket(ctx, tx, b)
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func bucketIndexKey(b *platform.Bucket) ([]byte, *platform.Error) {
|
func bucketIndexKey(b *platform.Bucket) ([]byte, *platform.Error) {
|
||||||
orgID, err := b.OrganizationID.Encode()
|
orgID, err := b.OrgID.Encode()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, &platform.Error{
|
return nil, &platform.Error{
|
||||||
Code: platform.EInvalid,
|
Code: platform.EInvalid,
|
||||||
|
@ -504,9 +473,6 @@ func (c *Client) forEachBucket(ctx context.Context, tx *bolt.Tx, descending bool
|
||||||
if err := json.Unmarshal(v, b); err != nil {
|
if err := json.Unmarshal(v, b); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := c.setOrganizationOnBucket(ctx, tx, b); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if !fn(b) {
|
if !fn(b) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -556,7 +522,7 @@ func (c *Client) updateBucket(ctx context.Context, tx *bolt.Tx, id platform.ID,
|
||||||
}
|
}
|
||||||
|
|
||||||
if upd.Name != nil {
|
if upd.Name != nil {
|
||||||
b0, err := c.findBucketByName(ctx, tx, b.OrganizationID, *upd.Name)
|
b0, err := c.findBucketByName(ctx, tx, b.OrgID, *upd.Name)
|
||||||
if err == nil && b0.ID != id {
|
if err == nil && b0.ID != id {
|
||||||
return nil, &platform.Error{
|
return nil, &platform.Error{
|
||||||
Code: platform.EConflict,
|
Code: platform.EConflict,
|
||||||
|
@ -582,11 +548,6 @@ func (c *Client) updateBucket(ctx context.Context, tx *bolt.Tx, id platform.ID,
|
||||||
if err := c.putBucket(ctx, tx, b); err != nil {
|
if err := c.putBucket(ctx, tx, b); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := c.setOrganizationOnBucket(ctx, tx, b); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@ func TestClient_Name(t *testing.T) {
|
||||||
})
|
})
|
||||||
return s.CreateBucket(ctx, &platform.Bucket{
|
return s.CreateBucket(ctx, &platform.Bucket{
|
||||||
Name: "b1",
|
Name: "b1",
|
||||||
OrganizationID: testID,
|
OrgID: testID,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -102,8 +102,7 @@ func (c *Client) Generate(ctx context.Context, req *platform.OnboardingRequest)
|
||||||
}
|
}
|
||||||
bucket := &platform.Bucket{
|
bucket := &platform.Bucket{
|
||||||
Name: req.Bucket,
|
Name: req.Bucket,
|
||||||
Org: o.Name,
|
OrgID: o.ID,
|
||||||
OrganizationID: o.ID,
|
|
||||||
RetentionPeriod: time.Duration(req.RetentionPeriod) * time.Hour,
|
RetentionPeriod: time.Duration(req.RetentionPeriod) * time.Hour,
|
||||||
}
|
}
|
||||||
if err = c.CreateBucket(ctx, bucket); err != nil {
|
if err = c.CreateBucket(ctx, bucket); err != nil {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/coreos/bbolt"
|
bolt "github.com/coreos/bbolt"
|
||||||
"github.com/influxdata/influxdb"
|
"github.com/influxdata/influxdb"
|
||||||
influxdbcontext "github.com/influxdata/influxdb/context"
|
influxdbcontext "github.com/influxdata/influxdb/context"
|
||||||
"github.com/influxdata/influxdb/kit/tracing"
|
"github.com/influxdata/influxdb/kit/tracing"
|
||||||
|
@ -507,7 +507,7 @@ func (c *Client) FindResourceOrganizationID(ctx context.Context, rt influxdb.Res
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return influxdb.InvalidID(), err
|
return influxdb.InvalidID(), err
|
||||||
}
|
}
|
||||||
return r.OrganizationID, nil
|
return r.OrgID, nil
|
||||||
case influxdb.DashboardsResourceType:
|
case influxdb.DashboardsResourceType:
|
||||||
r, err := c.FindDashboardByID(ctx, id)
|
r, err := c.FindDashboardByID(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -21,8 +21,7 @@ const InfiniteRetention = 0
|
||||||
// Bucket is a bucket. 🎉
|
// Bucket is a bucket. 🎉
|
||||||
type Bucket struct {
|
type Bucket struct {
|
||||||
ID ID `json:"id,omitempty"`
|
ID ID `json:"id,omitempty"`
|
||||||
OrganizationID ID `json:"orgID,omitempty"`
|
OrgID ID `json:"orgID,omitempty"`
|
||||||
Org string `json:"org,omitempty"`
|
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
RetentionPolicyName string `json:"rp,omitempty"` // This to support v1 sources
|
RetentionPolicyName string `json:"rp,omitempty"` // This to support v1 sources
|
||||||
RetentionPeriod time.Duration `json:"retentionPeriod"`
|
RetentionPeriod time.Duration `json:"retentionPeriod"`
|
||||||
|
|
|
@ -26,7 +26,6 @@ func bucketF(cmd *cobra.Command, args []string) {
|
||||||
// BucketCreateFlags define the Create Command
|
// BucketCreateFlags define the Create Command
|
||||||
type BucketCreateFlags struct {
|
type BucketCreateFlags struct {
|
||||||
name string
|
name string
|
||||||
org string
|
|
||||||
orgID string
|
orgID string
|
||||||
retention time.Duration
|
retention time.Duration
|
||||||
}
|
}
|
||||||
|
@ -42,7 +41,6 @@ func init() {
|
||||||
|
|
||||||
bucketCreateCmd.Flags().StringVarP(&bucketCreateFlags.name, "name", "n", "", "Name of bucket that will be created")
|
bucketCreateCmd.Flags().StringVarP(&bucketCreateFlags.name, "name", "n", "", "Name of bucket that will be created")
|
||||||
bucketCreateCmd.Flags().DurationVarP(&bucketCreateFlags.retention, "retention", "r", 0, "Duration in nanoseconds data will live in bucket")
|
bucketCreateCmd.Flags().DurationVarP(&bucketCreateFlags.retention, "retention", "r", 0, "Duration in nanoseconds data will live in bucket")
|
||||||
bucketCreateCmd.Flags().StringVarP(&bucketCreateFlags.org, "org", "o", "", "Name of the organization that owns the bucket")
|
|
||||||
bucketCreateCmd.Flags().StringVarP(&bucketCreateFlags.orgID, "org-id", "", "", "The ID of the organization that owns the bucket")
|
bucketCreateCmd.Flags().StringVarP(&bucketCreateFlags.orgID, "org-id", "", "", "The ID of the organization that owns the bucket")
|
||||||
bucketCreateCmd.MarkFlagRequired("name")
|
bucketCreateCmd.MarkFlagRequired("name")
|
||||||
|
|
||||||
|
@ -60,9 +58,8 @@ func newBucketService(f Flags) (platform.BucketService, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func bucketCreateF(cmd *cobra.Command, args []string) error {
|
func bucketCreateF(cmd *cobra.Command, args []string) error {
|
||||||
if (bucketCreateFlags.org == "" && bucketCreateFlags.orgID == "") ||
|
if bucketCreateFlags.orgID == "" {
|
||||||
(bucketCreateFlags.org != "" && bucketCreateFlags.orgID != "") {
|
return fmt.Errorf("must specify org-id")
|
||||||
return fmt.Errorf("must specify exactly one of org or org-id")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s, err := newBucketService(flags)
|
s, err := newBucketService(flags)
|
||||||
|
@ -75,16 +72,12 @@ func bucketCreateF(cmd *cobra.Command, args []string) error {
|
||||||
RetentionPeriod: bucketCreateFlags.retention,
|
RetentionPeriod: bucketCreateFlags.retention,
|
||||||
}
|
}
|
||||||
|
|
||||||
if bucketCreateFlags.org != "" {
|
|
||||||
b.Org = bucketCreateFlags.org
|
|
||||||
}
|
|
||||||
|
|
||||||
if bucketCreateFlags.orgID != "" {
|
if bucketCreateFlags.orgID != "" {
|
||||||
id, err := platform.IDFromString(bucketCreateFlags.orgID)
|
id, err := platform.IDFromString(bucketCreateFlags.orgID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to decode org id %q: %v", bucketCreateFlags.orgID, err)
|
return fmt.Errorf("failed to decode org id %q: %v", bucketCreateFlags.orgID, err)
|
||||||
}
|
}
|
||||||
b.OrganizationID = *id
|
b.OrgID = *id
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.CreateBucket(context.Background(), b); err != nil {
|
if err := s.CreateBucket(context.Background(), b); err != nil {
|
||||||
|
@ -103,8 +96,7 @@ func bucketCreateF(cmd *cobra.Command, args []string) error {
|
||||||
"ID": b.ID.String(),
|
"ID": b.ID.String(),
|
||||||
"Name": b.Name,
|
"Name": b.Name,
|
||||||
"Retention": b.RetentionPeriod,
|
"Retention": b.RetentionPeriod,
|
||||||
"Org": b.Org,
|
"OrgID": b.OrgID.String(),
|
||||||
"OrganizationID": b.OrganizationID.String(),
|
|
||||||
})
|
})
|
||||||
w.Flush()
|
w.Flush()
|
||||||
|
|
||||||
|
@ -189,8 +181,7 @@ func bucketFindF(cmd *cobra.Command, args []string) error {
|
||||||
"ID": b.ID.String(),
|
"ID": b.ID.String(),
|
||||||
"Name": b.Name,
|
"Name": b.Name,
|
||||||
"Retention": b.RetentionPeriod,
|
"Retention": b.RetentionPeriod,
|
||||||
"Org": b.Org,
|
"OrgID": b.OrgID.String(),
|
||||||
"OrganizationID": b.OrganizationID.String(),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
w.Flush()
|
w.Flush()
|
||||||
|
@ -258,8 +249,7 @@ func bucketUpdateF(cmd *cobra.Command, args []string) error {
|
||||||
"ID": b.ID.String(),
|
"ID": b.ID.String(),
|
||||||
"Name": b.Name,
|
"Name": b.Name,
|
||||||
"Retention": b.RetentionPeriod,
|
"Retention": b.RetentionPeriod,
|
||||||
"Org": b.Org,
|
"OrgID": b.OrgID.String(),
|
||||||
"OrganizationID": b.OrganizationID.String(),
|
|
||||||
})
|
})
|
||||||
w.Flush()
|
w.Flush()
|
||||||
|
|
||||||
|
@ -307,8 +297,7 @@ func bucketDeleteF(cmd *cobra.Command, args []string) error {
|
||||||
"ID": b.ID.String(),
|
"ID": b.ID.String(),
|
||||||
"Name": b.Name,
|
"Name": b.Name,
|
||||||
"Retention": b.RetentionPeriod,
|
"Retention": b.RetentionPeriod,
|
||||||
"Org": b.Org,
|
"OrgID": b.OrgID.String(),
|
||||||
"OrganizationID": b.OrganizationID.String(),
|
|
||||||
"Deleted": true,
|
"Deleted": true,
|
||||||
})
|
})
|
||||||
w.Flush()
|
w.Flush()
|
||||||
|
|
|
@ -126,7 +126,7 @@ func fluxWriteF(cmd *cobra.Command, args []string) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bucketID, orgID := buckets[0].ID, buckets[0].OrganizationID
|
bucketID, orgID := buckets[0].ID, buckets[0].OrgID
|
||||||
|
|
||||||
var r io.Reader
|
var r io.Reader
|
||||||
if args[0] == "-" {
|
if args[0] == "-" {
|
||||||
|
|
|
@ -26,11 +26,11 @@ func TestLauncher_Task(t *testing.T) {
|
||||||
now := time.Now().Unix() // Need to track now at the start of the test, for a query later.
|
now := time.Now().Unix() // Need to track now at the start of the test, for a query later.
|
||||||
org := be.Org
|
org := be.Org
|
||||||
|
|
||||||
bIn := &influxdb.Bucket{OrganizationID: org.ID, Org: org.Name, Name: "my_bucket_in"}
|
bIn := &influxdb.Bucket{OrgID: org.ID, Name: "my_bucket_in"}
|
||||||
if err := be.BucketService().CreateBucket(context.Background(), bIn); err != nil {
|
if err := be.BucketService().CreateBucket(context.Background(), bIn); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
bOut := &influxdb.Bucket{OrganizationID: org.ID, Org: org.Name, Name: "my_bucket_out"}
|
bOut := &influxdb.Bucket{OrgID: org.ID, Name: "my_bucket_out"}
|
||||||
if err := be.BucketService().CreateBucket(context.Background(), bOut); err != nil {
|
if err := be.BucketService().CreateBucket(context.Background(), bOut); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,8 +127,7 @@ func NewBucketHandler(b *BucketBackend) *BucketHandler {
|
||||||
// bucket is used for serialization/deserialization with duration string syntax.
|
// bucket is used for serialization/deserialization with duration string syntax.
|
||||||
type bucket struct {
|
type bucket struct {
|
||||||
ID influxdb.ID `json:"id,omitempty"`
|
ID influxdb.ID `json:"id,omitempty"`
|
||||||
OrganizationID influxdb.ID `json:"organizationID,omitempty"`
|
OrgID influxdb.ID `json:"orgID,omitempty"`
|
||||||
Org string `json:"org,omitempty"`
|
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
RetentionPolicyName string `json:"rp,omitempty"` // This to support v1 sources
|
RetentionPolicyName string `json:"rp,omitempty"` // This to support v1 sources
|
||||||
RetentionRules []retentionRule `json:"retentionRules"`
|
RetentionRules []retentionRule `json:"retentionRules"`
|
||||||
|
@ -160,8 +159,7 @@ func (b *bucket) toInfluxDB() (*influxdb.Bucket, error) {
|
||||||
|
|
||||||
return &influxdb.Bucket{
|
return &influxdb.Bucket{
|
||||||
ID: b.ID,
|
ID: b.ID,
|
||||||
OrganizationID: b.OrganizationID,
|
OrgID: b.OrgID,
|
||||||
Org: b.Org,
|
|
||||||
Name: b.Name,
|
Name: b.Name,
|
||||||
RetentionPolicyName: b.RetentionPolicyName,
|
RetentionPolicyName: b.RetentionPolicyName,
|
||||||
RetentionPeriod: d,
|
RetentionPeriod: d,
|
||||||
|
@ -184,8 +182,7 @@ func newBucket(pb *influxdb.Bucket) *bucket {
|
||||||
|
|
||||||
return &bucket{
|
return &bucket{
|
||||||
ID: pb.ID,
|
ID: pb.ID,
|
||||||
OrganizationID: pb.OrganizationID,
|
OrgID: pb.OrgID,
|
||||||
Org: pb.Org,
|
|
||||||
Name: pb.Name,
|
Name: pb.Name,
|
||||||
RetentionPolicyName: pb.RetentionPolicyName,
|
RetentionPolicyName: pb.RetentionPolicyName,
|
||||||
RetentionRules: rules,
|
RetentionRules: rules,
|
||||||
|
@ -253,10 +250,10 @@ func newBucketResponse(b *influxdb.Bucket, labels []*influxdb.Label) *bucketResp
|
||||||
"labels": fmt.Sprintf("/api/v2/buckets/%s/labels", b.ID),
|
"labels": fmt.Sprintf("/api/v2/buckets/%s/labels", b.ID),
|
||||||
"logs": fmt.Sprintf("/api/v2/buckets/%s/logs", b.ID),
|
"logs": fmt.Sprintf("/api/v2/buckets/%s/logs", b.ID),
|
||||||
"members": fmt.Sprintf("/api/v2/buckets/%s/members", b.ID),
|
"members": fmt.Sprintf("/api/v2/buckets/%s/members", b.ID),
|
||||||
"org": fmt.Sprintf("/api/v2/orgs/%s", b.OrganizationID),
|
"org": fmt.Sprintf("/api/v2/orgs/%s", b.OrgID),
|
||||||
"owners": fmt.Sprintf("/api/v2/buckets/%s/owners", b.ID),
|
"owners": fmt.Sprintf("/api/v2/buckets/%s/owners", b.ID),
|
||||||
"self": fmt.Sprintf("/api/v2/buckets/%s", b.ID),
|
"self": fmt.Sprintf("/api/v2/buckets/%s", b.ID),
|
||||||
"write": fmt.Sprintf("/api/v2/write?org=%s&bucket=%s", b.OrganizationID, b.ID),
|
"write": fmt.Sprintf("/api/v2/write?org=%s&bucket=%s", b.OrgID, b.ID),
|
||||||
},
|
},
|
||||||
bucket: *newBucket(b),
|
bucket: *newBucket(b),
|
||||||
Labels: []influxdb.Label{},
|
Labels: []influxdb.Label{},
|
||||||
|
@ -296,16 +293,6 @@ func (h *BucketHandler) handlePostBucket(w http.ResponseWriter, r *http.Request)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !req.Bucket.OrganizationID.Valid() {
|
|
||||||
// Resolve organization name to ID before create
|
|
||||||
o, err := h.OrganizationService.FindOrganization(ctx, influxdb.OrganizationFilter{Name: &req.Bucket.Org})
|
|
||||||
if err != nil {
|
|
||||||
EncodeError(ctx, err, w)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
req.Bucket.OrganizationID = o.ID
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := h.BucketService.CreateBucket(ctx, req.Bucket); err != nil {
|
if err := h.BucketService.CreateBucket(ctx, req.Bucket); err != nil {
|
||||||
EncodeError(ctx, err, w)
|
EncodeError(ctx, err, w)
|
||||||
return
|
return
|
||||||
|
@ -322,7 +309,7 @@ type postBucketRequest struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b postBucketRequest) Validate() error {
|
func (b postBucketRequest) Validate() error {
|
||||||
if b.Bucket.Org == "" && !b.Bucket.OrganizationID.Valid() {
|
if !b.Bucket.OrgID.Valid() {
|
||||||
return fmt.Errorf("bucket requires an organization")
|
return fmt.Errorf("bucket requires an organization")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -62,13 +62,13 @@ func TestService_handleGetBuckets(t *testing.T) {
|
||||||
{
|
{
|
||||||
ID: platformtesting.MustIDBase16("0b501e7e557ab1ed"),
|
ID: platformtesting.MustIDBase16("0b501e7e557ab1ed"),
|
||||||
Name: "hello",
|
Name: "hello",
|
||||||
OrganizationID: platformtesting.MustIDBase16("50f7ba1150f7ba11"),
|
OrgID: platformtesting.MustIDBase16("50f7ba1150f7ba11"),
|
||||||
RetentionPeriod: 2 * time.Second,
|
RetentionPeriod: 2 * time.Second,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: platformtesting.MustIDBase16("c0175f0077a77005"),
|
ID: platformtesting.MustIDBase16("c0175f0077a77005"),
|
||||||
Name: "example",
|
Name: "example",
|
||||||
OrganizationID: platformtesting.MustIDBase16("7e55e118dbabb1ed"),
|
OrgID: platformtesting.MustIDBase16("7e55e118dbabb1ed"),
|
||||||
RetentionPeriod: 24 * time.Hour,
|
RetentionPeriod: 24 * time.Hour,
|
||||||
},
|
},
|
||||||
}, 2, nil
|
}, 2, nil
|
||||||
|
@ -115,7 +115,7 @@ func TestService_handleGetBuckets(t *testing.T) {
|
||||||
"write": "/api/v2/write?org=50f7ba1150f7ba11&bucket=0b501e7e557ab1ed"
|
"write": "/api/v2/write?org=50f7ba1150f7ba11&bucket=0b501e7e557ab1ed"
|
||||||
},
|
},
|
||||||
"id": "0b501e7e557ab1ed",
|
"id": "0b501e7e557ab1ed",
|
||||||
"organizationID": "50f7ba1150f7ba11",
|
"orgID": "50f7ba1150f7ba11",
|
||||||
"name": "hello",
|
"name": "hello",
|
||||||
"retentionRules": [{"type": "expire", "everySeconds": 2}],
|
"retentionRules": [{"type": "expire", "everySeconds": 2}],
|
||||||
"labels": [
|
"labels": [
|
||||||
|
@ -139,7 +139,7 @@ func TestService_handleGetBuckets(t *testing.T) {
|
||||||
"write": "/api/v2/write?org=7e55e118dbabb1ed&bucket=c0175f0077a77005"
|
"write": "/api/v2/write?org=7e55e118dbabb1ed&bucket=c0175f0077a77005"
|
||||||
},
|
},
|
||||||
"id": "c0175f0077a77005",
|
"id": "c0175f0077a77005",
|
||||||
"organizationID": "7e55e118dbabb1ed",
|
"orgID": "7e55e118dbabb1ed",
|
||||||
"name": "example",
|
"name": "example",
|
||||||
"retentionRules": [{"type": "expire", "everySeconds": 86400}],
|
"retentionRules": [{"type": "expire", "everySeconds": 86400}],
|
||||||
"labels": [
|
"labels": [
|
||||||
|
@ -251,7 +251,7 @@ func TestService_handleGetBucket(t *testing.T) {
|
||||||
if id == platformtesting.MustIDBase16("020f755c3c082000") {
|
if id == platformtesting.MustIDBase16("020f755c3c082000") {
|
||||||
return &platform.Bucket{
|
return &platform.Bucket{
|
||||||
ID: platformtesting.MustIDBase16("020f755c3c082000"),
|
ID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||||
OrganizationID: platformtesting.MustIDBase16("020f755c3c082000"),
|
OrgID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||||
Name: "hello",
|
Name: "hello",
|
||||||
RetentionPeriod: 30 * time.Second,
|
RetentionPeriod: 30 * time.Second,
|
||||||
}, nil
|
}, nil
|
||||||
|
@ -279,7 +279,7 @@ func TestService_handleGetBucket(t *testing.T) {
|
||||||
"write": "/api/v2/write?org=020f755c3c082000&bucket=020f755c3c082000"
|
"write": "/api/v2/write?org=020f755c3c082000&bucket=020f755c3c082000"
|
||||||
},
|
},
|
||||||
"id": "020f755c3c082000",
|
"id": "020f755c3c082000",
|
||||||
"organizationID": "020f755c3c082000",
|
"orgID": "020f755c3c082000",
|
||||||
"name": "hello",
|
"name": "hello",
|
||||||
"retentionRules": [{"type": "expire", "everySeconds": 30}],
|
"retentionRules": [{"type": "expire", "everySeconds": 30}],
|
||||||
"labels": []
|
"labels": []
|
||||||
|
@ -386,7 +386,7 @@ func TestService_handlePostBucket(t *testing.T) {
|
||||||
args: args{
|
args: args{
|
||||||
bucket: &platform.Bucket{
|
bucket: &platform.Bucket{
|
||||||
Name: "hello",
|
Name: "hello",
|
||||||
OrganizationID: platformtesting.MustIDBase16("6f626f7274697320"),
|
OrgID: platformtesting.MustIDBase16("6f626f7274697320"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wants: wants{
|
wants: wants{
|
||||||
|
@ -404,7 +404,7 @@ func TestService_handlePostBucket(t *testing.T) {
|
||||||
"write": "/api/v2/write?org=6f626f7274697320&bucket=020f755c3c082000"
|
"write": "/api/v2/write?org=6f626f7274697320&bucket=020f755c3c082000"
|
||||||
},
|
},
|
||||||
"id": "020f755c3c082000",
|
"id": "020f755c3c082000",
|
||||||
"organizationID": "6f626f7274697320",
|
"orgID": "6f626f7274697320",
|
||||||
"name": "hello",
|
"name": "hello",
|
||||||
"retentionRules": [],
|
"retentionRules": [],
|
||||||
"labels": []
|
"labels": []
|
||||||
|
@ -577,7 +577,7 @@ func TestService_handlePatchBucket(t *testing.T) {
|
||||||
d := &platform.Bucket{
|
d := &platform.Bucket{
|
||||||
ID: platformtesting.MustIDBase16("020f755c3c082000"),
|
ID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||||
Name: "hello",
|
Name: "hello",
|
||||||
OrganizationID: platformtesting.MustIDBase16("020f755c3c082000"),
|
OrgID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||||
}
|
}
|
||||||
|
|
||||||
if upd.Name != nil {
|
if upd.Name != nil {
|
||||||
|
@ -615,7 +615,7 @@ func TestService_handlePatchBucket(t *testing.T) {
|
||||||
"write": "/api/v2/write?org=020f755c3c082000&bucket=020f755c3c082000"
|
"write": "/api/v2/write?org=020f755c3c082000&bucket=020f755c3c082000"
|
||||||
},
|
},
|
||||||
"id": "020f755c3c082000",
|
"id": "020f755c3c082000",
|
||||||
"organizationID": "020f755c3c082000",
|
"orgID": "020f755c3c082000",
|
||||||
"name": "example",
|
"name": "example",
|
||||||
"retentionRules": [{"type": "expire", "everySeconds": 2}],
|
"retentionRules": [{"type": "expire", "everySeconds": 2}],
|
||||||
"labels": []
|
"labels": []
|
||||||
|
@ -653,7 +653,7 @@ func TestService_handlePatchBucket(t *testing.T) {
|
||||||
d := &platform.Bucket{
|
d := &platform.Bucket{
|
||||||
ID: platformtesting.MustIDBase16("020f755c3c082000"),
|
ID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||||
Name: "hello",
|
Name: "hello",
|
||||||
OrganizationID: platformtesting.MustIDBase16("020f755c3c082000"),
|
OrgID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||||
}
|
}
|
||||||
|
|
||||||
if upd.Name != nil {
|
if upd.Name != nil {
|
||||||
|
@ -691,7 +691,7 @@ func TestService_handlePatchBucket(t *testing.T) {
|
||||||
"write": "/api/v2/write?org=020f755c3c082000&bucket=020f755c3c082000"
|
"write": "/api/v2/write?org=020f755c3c082000&bucket=020f755c3c082000"
|
||||||
},
|
},
|
||||||
"id": "020f755c3c082000",
|
"id": "020f755c3c082000",
|
||||||
"organizationID": "020f755c3c082000",
|
"orgID": "020f755c3c082000",
|
||||||
"name": "bucket with no retention",
|
"name": "bucket with no retention",
|
||||||
"retentionRules": [],
|
"retentionRules": [],
|
||||||
"labels": []
|
"labels": []
|
||||||
|
@ -708,7 +708,7 @@ func TestService_handlePatchBucket(t *testing.T) {
|
||||||
d := &platform.Bucket{
|
d := &platform.Bucket{
|
||||||
ID: platformtesting.MustIDBase16("020f755c3c082000"),
|
ID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||||
Name: "b1",
|
Name: "b1",
|
||||||
OrganizationID: platformtesting.MustIDBase16("020f755c3c082000"),
|
OrgID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||||
}
|
}
|
||||||
|
|
||||||
if upd.Name != nil {
|
if upd.Name != nil {
|
||||||
|
@ -748,7 +748,7 @@ func TestService_handlePatchBucket(t *testing.T) {
|
||||||
"write": "/api/v2/write?org=020f755c3c082000&bucket=020f755c3c082000"
|
"write": "/api/v2/write?org=020f755c3c082000&bucket=020f755c3c082000"
|
||||||
},
|
},
|
||||||
"id": "020f755c3c082000",
|
"id": "020f755c3c082000",
|
||||||
"organizationID": "020f755c3c082000",
|
"orgID": "020f755c3c082000",
|
||||||
"name": "b1",
|
"name": "b1",
|
||||||
"retentionRules": [],
|
"retentionRules": [],
|
||||||
"labels": []
|
"labels": []
|
||||||
|
@ -765,7 +765,7 @@ func TestService_handlePatchBucket(t *testing.T) {
|
||||||
d := &platform.Bucket{
|
d := &platform.Bucket{
|
||||||
ID: platformtesting.MustIDBase16("020f755c3c082000"),
|
ID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||||
Name: "hello",
|
Name: "hello",
|
||||||
OrganizationID: platformtesting.MustIDBase16("020f755c3c082000"),
|
OrgID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||||
}
|
}
|
||||||
|
|
||||||
if upd.Name != nil {
|
if upd.Name != nil {
|
||||||
|
|
|
@ -1133,11 +1133,11 @@ func TestTaskHandler_CreateTaskWithOrgName(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Source and destination buckets for use in task.
|
// Source and destination buckets for use in task.
|
||||||
bSrc := platform.Bucket{OrganizationID: o.ID, Name: "b-src"}
|
bSrc := platform.Bucket{OrgID: o.ID, Name: "b-src"}
|
||||||
if err := i.CreateBucket(ctx, &bSrc); err != nil {
|
if err := i.CreateBucket(ctx, &bSrc); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
bDst := platform.Bucket{OrganizationID: o.ID, Name: "b-dst"}
|
bDst := platform.Bucket{OrgID: o.ID, Name: "b-dst"}
|
||||||
if err := i.CreateBucket(ctx, &bDst); err != nil {
|
if err := i.CreateBucket(ctx, &bDst); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -1240,11 +1240,11 @@ func TestTaskHandler_Sessions(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Source and destination buckets for use in task.
|
// Source and destination buckets for use in task.
|
||||||
bSrc := platform.Bucket{OrganizationID: o.ID, Name: "b-src"}
|
bSrc := platform.Bucket{OrgID: o.ID, Name: "b-src"}
|
||||||
if err := i.CreateBucket(ctx, &bSrc); err != nil {
|
if err := i.CreateBucket(ctx, &bSrc); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
bDst := platform.Bucket{OrganizationID: o.ID, Name: "b-dst"}
|
bDst := platform.Bucket{OrgID: o.ID, Name: "b-dst"}
|
||||||
if err := i.CreateBucket(ctx, &bDst); err != nil {
|
if err := i.CreateBucket(ctx, &bDst); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,25 +29,9 @@ func (s *Service) loadBucket(ctx context.Context, id platform.ID) (*platform.Buc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.setOrganizationNameOnBucket(ctx, &b); err != nil {
|
|
||||||
return nil, &platform.Error{
|
|
||||||
Err: err,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return &b, nil
|
return &b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) setOrganizationNameOnBucket(ctx context.Context, b *platform.Bucket) error {
|
|
||||||
o, err := s.loadOrganization(b.OrganizationID)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
b.Org = o.Name
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// FindBucketByID returns a single bucket by ID.
|
// FindBucketByID returns a single bucket by ID.
|
||||||
func (s *Service) FindBucketByID(ctx context.Context, id platform.ID) (*platform.Bucket, error) {
|
func (s *Service) FindBucketByID(ctx context.Context, id platform.ID) (*platform.Bucket, error) {
|
||||||
var b *platform.Bucket
|
var b *platform.Bucket
|
||||||
|
@ -199,7 +183,7 @@ func (s *Service) findBuckets(ctx context.Context, filter platform.BucketFilter,
|
||||||
|
|
||||||
if filter.Name != nil && filter.OrganizationID != nil {
|
if filter.Name != nil && filter.OrganizationID != nil {
|
||||||
filterFunc = func(b *platform.Bucket) bool {
|
filterFunc = func(b *platform.Bucket) bool {
|
||||||
return b.Name == *filter.Name && b.OrganizationID == *filter.OrganizationID
|
return b.Name == *filter.Name && b.OrgID == *filter.OrganizationID
|
||||||
}
|
}
|
||||||
} else if filter.Name != nil {
|
} else if filter.Name != nil {
|
||||||
// filter by bucket name
|
// filter by bucket name
|
||||||
|
@ -209,7 +193,7 @@ func (s *Service) findBuckets(ctx context.Context, filter platform.BucketFilter,
|
||||||
} else if filter.OrganizationID != nil {
|
} else if filter.OrganizationID != nil {
|
||||||
// filter by organization id
|
// filter by organization id
|
||||||
filterFunc = func(b *platform.Bucket) bool {
|
filterFunc = func(b *platform.Bucket) bool {
|
||||||
return b.OrganizationID == *filter.OrganizationID
|
return b.OrgID == *filter.OrganizationID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,37 +216,23 @@ func (s *Service) FindBuckets(ctx context.Context, filter platform.BucketFilter,
|
||||||
err = pe
|
err = pe
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
for _, b := range bs {
|
|
||||||
if err := s.setOrganizationNameOnBucket(ctx, b); err != nil {
|
|
||||||
return nil, 0, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return bs, len(bs), nil
|
return bs, len(bs), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateBucket creates a new bucket and sets b.ID with the new identifier.
|
// CreateBucket creates a new bucket and sets b.ID with the new identifier.
|
||||||
func (s *Service) CreateBucket(ctx context.Context, b *platform.Bucket) error {
|
func (s *Service) CreateBucket(ctx context.Context, b *platform.Bucket) error {
|
||||||
if b.OrganizationID.Valid() {
|
if b.OrgID.Valid() {
|
||||||
_, pe := s.FindOrganizationByID(ctx, b.OrganizationID)
|
_, pe := s.FindOrganizationByID(ctx, b.OrgID)
|
||||||
if pe != nil {
|
if pe != nil {
|
||||||
return &platform.Error{
|
return &platform.Error{
|
||||||
Err: pe,
|
Err: pe,
|
||||||
Op: OpPrefix + platform.OpCreateBucket,
|
Op: OpPrefix + platform.OpCreateBucket,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
o, pe := s.findOrganizationByName(ctx, b.Org)
|
|
||||||
if pe != nil {
|
|
||||||
return &platform.Error{
|
|
||||||
Err: pe,
|
|
||||||
Op: OpPrefix + platform.OpCreateBucket,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
b.OrganizationID = o.ID
|
|
||||||
}
|
}
|
||||||
filter := platform.BucketFilter{
|
filter := platform.BucketFilter{
|
||||||
Name: &b.Name,
|
Name: &b.Name,
|
||||||
OrganizationID: &b.OrganizationID,
|
OrganizationID: &b.OrgID,
|
||||||
}
|
}
|
||||||
if _, err := s.FindBucket(ctx, filter); err == nil {
|
if _, err := s.FindBucket(ctx, filter); err == nil {
|
||||||
return &platform.Error{
|
return &platform.Error{
|
||||||
|
|
|
@ -78,7 +78,7 @@ func TestService_Name(t *testing.T) {
|
||||||
})
|
})
|
||||||
return s.CreateBucket(ctx, &platform.Bucket{
|
return s.CreateBucket(ctx, &platform.Bucket{
|
||||||
Name: "b1",
|
Name: "b1",
|
||||||
OrganizationID: testID,
|
OrgID: testID,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -85,8 +85,7 @@ func (s *Service) Generate(ctx context.Context, req *platform.OnboardingRequest)
|
||||||
}
|
}
|
||||||
bucket := &platform.Bucket{
|
bucket := &platform.Bucket{
|
||||||
Name: req.Bucket,
|
Name: req.Bucket,
|
||||||
Org: o.Name,
|
OrgID: o.ID,
|
||||||
OrganizationID: o.ID,
|
|
||||||
RetentionPeriod: time.Duration(req.RetentionPeriod) * time.Hour,
|
RetentionPeriod: time.Duration(req.RetentionPeriod) * time.Hour,
|
||||||
}
|
}
|
||||||
if err = s.CreateBucket(ctx, bucket); err != nil {
|
if err = s.CreateBucket(ctx, bucket); err != nil {
|
||||||
|
|
60
kv/bucket.go
60
kv/bucket.go
|
@ -47,20 +47,6 @@ func (s *Service) bucketsIndexBucket(tx Tx) (Bucket, error) {
|
||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) setOrganizationOnBucket(ctx context.Context, tx Tx, b *influxdb.Bucket) error {
|
|
||||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
|
||||||
defer span.Finish()
|
|
||||||
|
|
||||||
o, err := s.findOrganizationByID(ctx, tx, b.OrganizationID)
|
|
||||||
if err != nil {
|
|
||||||
return &influxdb.Error{
|
|
||||||
Err: err,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
b.Org = o.Name
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// FindBucketByID retrieves a bucket by id.
|
// FindBucketByID retrieves a bucket by id.
|
||||||
func (s *Service) FindBucketByID(ctx context.Context, id influxdb.ID) (*influxdb.Bucket, error) {
|
func (s *Service) FindBucketByID(ctx context.Context, id influxdb.ID) (*influxdb.Bucket, error) {
|
||||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
span, ctx := tracing.StartSpanFromContext(ctx)
|
||||||
|
@ -87,7 +73,7 @@ func (s *Service) FindBucketByID(ctx context.Context, id influxdb.ID) (*influxdb
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) findBucketByID(ctx context.Context, tx Tx, id influxdb.ID) (*influxdb.Bucket, error) {
|
func (s *Service) findBucketByID(ctx context.Context, tx Tx, id influxdb.ID) (*influxdb.Bucket, error) {
|
||||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
span, _ := tracing.StartSpanFromContext(ctx)
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
|
|
||||||
var b influxdb.Bucket
|
var b influxdb.Bucket
|
||||||
|
@ -123,12 +109,6 @@ func (s *Service) findBucketByID(ctx context.Context, tx Tx, id influxdb.ID) (*i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.setOrganizationOnBucket(ctx, tx, &b); err != nil {
|
|
||||||
return nil, &influxdb.Error{
|
|
||||||
Err: err,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return &b, nil
|
return &b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +139,7 @@ func (s *Service) findBucketByName(ctx context.Context, tx Tx, orgID influxdb.ID
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
|
|
||||||
b := &influxdb.Bucket{
|
b := &influxdb.Bucket{
|
||||||
OrganizationID: orgID,
|
OrgID: orgID,
|
||||||
Name: n,
|
Name: n,
|
||||||
}
|
}
|
||||||
key, err := bucketIndexKey(b)
|
key, err := bucketIndexKey(b)
|
||||||
|
@ -264,7 +244,7 @@ func filterBucketsFn(filter influxdb.BucketFilter) func(b *influxdb.Bucket) bool
|
||||||
|
|
||||||
if filter.Name != nil && filter.OrganizationID != nil {
|
if filter.Name != nil && filter.OrganizationID != nil {
|
||||||
return func(b *influxdb.Bucket) bool {
|
return func(b *influxdb.Bucket) bool {
|
||||||
return b.Name == *filter.Name && b.OrganizationID == *filter.OrganizationID
|
return b.Name == *filter.Name && b.OrgID == *filter.OrganizationID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,7 +256,7 @@ func filterBucketsFn(filter influxdb.BucketFilter) func(b *influxdb.Bucket) bool
|
||||||
|
|
||||||
if filter.OrganizationID != nil {
|
if filter.OrganizationID != nil {
|
||||||
return func(b *influxdb.Bucket) bool {
|
return func(b *influxdb.Bucket) bool {
|
||||||
return b.OrganizationID == *filter.OrganizationID
|
return b.OrgID == *filter.OrganizationID
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,24 +364,16 @@ func (s *Service) CreateBucket(ctx context.Context, b *influxdb.Bucket) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) createBucket(ctx context.Context, tx Tx, b *influxdb.Bucket) error {
|
func (s *Service) createBucket(ctx context.Context, tx Tx, b *influxdb.Bucket) error {
|
||||||
if b.OrganizationID.Valid() {
|
if b.OrgID.Valid() {
|
||||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
span, ctx := tracing.StartSpanFromContext(ctx)
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
|
|
||||||
_, pe := s.findOrganizationByID(ctx, tx, b.OrganizationID)
|
_, pe := s.findOrganizationByID(ctx, tx, b.OrgID)
|
||||||
if pe != nil {
|
if pe != nil {
|
||||||
return &influxdb.Error{
|
return &influxdb.Error{
|
||||||
Err: pe,
|
Err: pe,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
o, pe := s.findOrganizationByName(ctx, tx, b.Org)
|
|
||||||
if pe != nil {
|
|
||||||
return &influxdb.Error{
|
|
||||||
Err: pe,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
b.OrganizationID = o.ID
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the bucket name is not unique for this organization, then, do not
|
// if the bucket name is not unique for this organization, then, do not
|
||||||
|
@ -446,7 +418,7 @@ func (s *Service) createBucketUserResourceMappings(ctx context.Context, tx Tx, b
|
||||||
|
|
||||||
ms, err := s.findUserResourceMappings(ctx, tx, influxdb.UserResourceMappingFilter{
|
ms, err := s.findUserResourceMappings(ctx, tx, influxdb.UserResourceMappingFilter{
|
||||||
ResourceType: influxdb.OrgsResourceType,
|
ResourceType: influxdb.OrgsResourceType,
|
||||||
ResourceID: b.OrganizationID,
|
ResourceID: b.OrgID,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &influxdb.Error{
|
return &influxdb.Error{
|
||||||
|
@ -471,10 +443,9 @@ func (s *Service) createBucketUserResourceMappings(ctx context.Context, tx Tx, b
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) putBucket(ctx context.Context, tx Tx, b *influxdb.Bucket) error {
|
func (s *Service) putBucket(ctx context.Context, tx Tx, b *influxdb.Bucket) error {
|
||||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
span, _ := tracing.StartSpanFromContext(ctx)
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
|
|
||||||
b.Org = ""
|
|
||||||
v, err := json.Marshal(b)
|
v, err := json.Marshal(b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &influxdb.Error{
|
return &influxdb.Error{
|
||||||
|
@ -510,12 +481,12 @@ func (s *Service) putBucket(ctx context.Context, tx Tx, b *influxdb.Bucket) erro
|
||||||
Err: err,
|
Err: err,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return s.setOrganizationOnBucket(ctx, tx, b)
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// bucketIndexKey is a combination of the orgID and the bucket name.
|
// bucketIndexKey is a combination of the orgID and the bucket name.
|
||||||
func bucketIndexKey(b *influxdb.Bucket) ([]byte, error) {
|
func bucketIndexKey(b *influxdb.Bucket) ([]byte, error) {
|
||||||
orgID, err := b.OrganizationID.Encode()
|
orgID, err := b.OrgID.Encode()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, &influxdb.Error{
|
return nil, &influxdb.Error{
|
||||||
Code: influxdb.EInvalid,
|
Code: influxdb.EInvalid,
|
||||||
|
@ -530,7 +501,7 @@ func bucketIndexKey(b *influxdb.Bucket) ([]byte, error) {
|
||||||
|
|
||||||
// forEachBucket will iterate through all buckets while fn returns true.
|
// forEachBucket will iterate through all buckets while fn returns true.
|
||||||
func (s *Service) forEachBucket(ctx context.Context, tx Tx, descending bool, fn func(*influxdb.Bucket) bool) error {
|
func (s *Service) forEachBucket(ctx context.Context, tx Tx, descending bool, fn func(*influxdb.Bucket) bool) error {
|
||||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
span, _ := tracing.StartSpanFromContext(ctx)
|
||||||
defer span.Finish()
|
defer span.Finish()
|
||||||
|
|
||||||
bkt, err := s.bucketsBucket(tx)
|
bkt, err := s.bucketsBucket(tx)
|
||||||
|
@ -555,9 +526,6 @@ func (s *Service) forEachBucket(ctx context.Context, tx Tx, descending bool, fn
|
||||||
if err := json.Unmarshal(v, b); err != nil {
|
if err := json.Unmarshal(v, b); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := s.setOrganizationOnBucket(ctx, tx, b); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if !fn(b) {
|
if !fn(b) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -622,7 +590,7 @@ func (s *Service) updateBucket(ctx context.Context, tx Tx, id influxdb.ID, upd i
|
||||||
}
|
}
|
||||||
|
|
||||||
if upd.Name != nil {
|
if upd.Name != nil {
|
||||||
b0, err := s.findBucketByName(ctx, tx, b.OrganizationID, *upd.Name)
|
b0, err := s.findBucketByName(ctx, tx, b.OrgID, *upd.Name)
|
||||||
if err == nil && b0.ID != id {
|
if err == nil && b0.ID != id {
|
||||||
return nil, &influxdb.Error{
|
return nil, &influxdb.Error{
|
||||||
Code: influxdb.EConflict,
|
Code: influxdb.EConflict,
|
||||||
|
@ -652,10 +620,6 @@ func (s *Service) updateBucket(ctx context.Context, tx Tx, id influxdb.ID, upd i
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := s.setOrganizationOnBucket(ctx, tx, b); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return b, nil
|
return b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ func testLookupName(newStore StoreFn, t *testing.T) {
|
||||||
})
|
})
|
||||||
return s.CreateBucket(ctx, &influxdb.Bucket{
|
return s.CreateBucket(ctx, &influxdb.Bucket{
|
||||||
Name: "b1",
|
Name: "b1",
|
||||||
OrganizationID: testID,
|
OrgID: testID,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -116,7 +116,6 @@ func (s *Service) Generate(ctx context.Context, req *influxdb.OnboardingRequest)
|
||||||
o := &influxdb.Organization{Name: req.Org}
|
o := &influxdb.Organization{Name: req.Org}
|
||||||
bucket := &influxdb.Bucket{
|
bucket := &influxdb.Bucket{
|
||||||
Name: req.Bucket,
|
Name: req.Bucket,
|
||||||
Org: o.Name,
|
|
||||||
RetentionPeriod: time.Duration(req.RetentionPeriod) * time.Hour,
|
RetentionPeriod: time.Duration(req.RetentionPeriod) * time.Hour,
|
||||||
}
|
}
|
||||||
mapping := &influxdb.UserResourceMapping{
|
mapping := &influxdb.UserResourceMapping{
|
||||||
|
@ -142,7 +141,7 @@ func (s *Service) Generate(ctx context.Context, req *influxdb.OnboardingRequest)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
bucket.OrganizationID = o.ID
|
bucket.OrgID = o.ID
|
||||||
if err := s.createBucket(ctx, tx, bucket); err != nil {
|
if err := s.createBucket(ctx, tx, bucket); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -417,7 +417,7 @@ func (s *Service) deleteOrganizationsBuckets(ctx context.Context, tx Tx, id infl
|
||||||
}
|
}
|
||||||
for _, b := range bs {
|
for _, b := range bs {
|
||||||
if err := s.deleteBucket(ctx, tx, b.ID); err != nil {
|
if err := s.deleteBucket(ctx, tx, b.ID); err != nil {
|
||||||
s.Logger.Warn("bucket was not deleted", zap.Stringer("bucketID", b.ID), zap.Stringer("orgID", b.OrganizationID))
|
s.Logger.Warn("bucket was not deleted", zap.Stringer("bucketID", b.ID), zap.Stringer("orgID", b.OrgID))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -583,7 +583,7 @@ func (s *Service) FindResourceOrganizationID(ctx context.Context, rt influxdb.Re
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return influxdb.InvalidID(), err
|
return influxdb.InvalidID(), err
|
||||||
}
|
}
|
||||||
return r.OrganizationID, nil
|
return r.OrgID, nil
|
||||||
case influxdb.OrgsResourceType:
|
case influxdb.OrgsResourceType:
|
||||||
r, err := s.FindOrganizationByID(ctx, id)
|
r, err := s.FindOrganizationByID(ctx, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -44,7 +44,7 @@ func (a *preAuthorizer) PreAuthorize(ctx context.Context, ast *ast.Package, auth
|
||||||
return errors.New("bucket service returned nil bucket")
|
return errors.New("bucket service returned nil bucket")
|
||||||
}
|
}
|
||||||
|
|
||||||
reqPerm, err := platform.NewPermissionAtID(bucket.ID, platform.ReadAction, platform.BucketsResourceType, bucket.OrganizationID)
|
reqPerm, err := platform.NewPermissionAtID(bucket.ID, platform.ReadAction, platform.BucketsResourceType, bucket.OrgID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "could not create read bucket permission")
|
return errors.Wrapf(err, "could not create read bucket permission")
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ func (a *preAuthorizer) PreAuthorize(ctx context.Context, ast *ast.Package, auth
|
||||||
return errors.Wrapf(err, "could not find write bucket with filter: %s", writeBucketFilter)
|
return errors.Wrapf(err, "could not find write bucket with filter: %s", writeBucketFilter)
|
||||||
}
|
}
|
||||||
|
|
||||||
reqPerm, err := platform.NewPermissionAtID(bucket.ID, platform.WriteAction, platform.BucketsResourceType, bucket.OrganizationID)
|
reqPerm, err := platform.NewPermissionAtID(bucket.ID, platform.WriteAction, platform.BucketsResourceType, bucket.OrgID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrapf(err, "could not create write bucket permission")
|
return errors.Wrapf(err, "could not create write bucket permission")
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ func (a *preAuthorizer) RequiredPermissions(ctx context.Context, ast *ast.Packag
|
||||||
return nil, errors.New("bucket service returned nil bucket")
|
return nil, errors.New("bucket service returned nil bucket")
|
||||||
}
|
}
|
||||||
|
|
||||||
reqPerm, err := platform.NewPermissionAtID(bucket.ID, platform.ReadAction, platform.BucketsResourceType, bucket.OrganizationID)
|
reqPerm, err := platform.NewPermissionAtID(bucket.ID, platform.ReadAction, platform.BucketsResourceType, bucket.OrgID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "could not create read bucket permission")
|
return nil, errors.Wrapf(err, "could not create read bucket permission")
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ func (a *preAuthorizer) RequiredPermissions(ctx context.Context, ast *ast.Packag
|
||||||
return nil, errors.Wrapf(err, "could not find write bucket with filter: %s", writeBucketFilter)
|
return nil, errors.Wrapf(err, "could not find write bucket with filter: %s", writeBucketFilter)
|
||||||
}
|
}
|
||||||
|
|
||||||
reqPerm, err := platform.NewPermissionAtID(bucket.ID, platform.WriteAction, platform.BucketsResourceType, bucket.OrganizationID)
|
reqPerm, err := platform.NewPermissionAtID(bucket.ID, platform.WriteAction, platform.BucketsResourceType, bucket.OrgID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "could not create write bucket permission")
|
return nil, errors.Wrapf(err, "could not create write bucket permission")
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ func TestPreAuthorizer_PreAuthorize(t *testing.T) {
|
||||||
bucketService := newBucketServiceWithOneBucket(platform.Bucket{
|
bucketService := newBucketServiceWithOneBucket(platform.Bucket{
|
||||||
Name: "my_bucket",
|
Name: "my_bucket",
|
||||||
ID: *bucketID,
|
ID: *bucketID,
|
||||||
OrganizationID: orgID,
|
OrgID: orgID,
|
||||||
})
|
})
|
||||||
|
|
||||||
preAuthorizer = query.NewPreAuthorizer(bucketService)
|
preAuthorizer = query.NewPreAuthorizer(bucketService)
|
||||||
|
@ -102,11 +102,11 @@ func TestPreAuthorizer_RequiredPermissions(t *testing.T) {
|
||||||
if err := i.CreateOrganization(ctx, &o); err != nil {
|
if err := i.CreateOrganization(ctx, &o); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
bFrom := platform.Bucket{Name: "b-from", OrganizationID: o.ID}
|
bFrom := platform.Bucket{Name: "b-from", OrgID: o.ID}
|
||||||
if err := i.CreateBucket(ctx, &bFrom); err != nil {
|
if err := i.CreateBucket(ctx, &bFrom); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
bTo := platform.Bucket{Name: "b-to", OrganizationID: o.ID}
|
bTo := platform.Bucket{Name: "b-to", OrgID: o.ID}
|
||||||
if err := i.CreateBucket(ctx, &bTo); err != nil {
|
if err := i.CreateBucket(ctx, &bTo); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ func (bd *BucketsDecoder) Fetch() (bool, error) {
|
||||||
|
|
||||||
func (bd *BucketsDecoder) Decode() (flux.Table, error) {
|
func (bd *BucketsDecoder) Decode() (flux.Table, error) {
|
||||||
kb := execute.NewGroupKeyBuilder(nil)
|
kb := execute.NewGroupKeyBuilder(nil)
|
||||||
kb.AddKeyValue("organizationID", values.NewString(bd.buckets[0].OrganizationID.String()))
|
kb.AddKeyValue("organizationID", values.NewString(bd.buckets[0].OrgID.String()))
|
||||||
gk, err := kb.Build()
|
gk, err := kb.Build()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -60,12 +60,6 @@ func (bd *BucketsDecoder) Decode() (flux.Table, error) {
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if _, err := b.AddCol(flux.ColMeta{
|
|
||||||
Label: "organization",
|
|
||||||
Type: flux.TString,
|
|
||||||
}); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if _, err := b.AddCol(flux.ColMeta{
|
if _, err := b.AddCol(flux.ColMeta{
|
||||||
Label: "organizationID",
|
Label: "organizationID",
|
||||||
Type: flux.TString,
|
Type: flux.TString,
|
||||||
|
@ -88,10 +82,9 @@ func (bd *BucketsDecoder) Decode() (flux.Table, error) {
|
||||||
for _, bucket := range bd.buckets {
|
for _, bucket := range bd.buckets {
|
||||||
_ = b.AppendString(0, bucket.Name)
|
_ = b.AppendString(0, bucket.Name)
|
||||||
_ = b.AppendString(1, bucket.ID.String())
|
_ = b.AppendString(1, bucket.ID.String())
|
||||||
_ = b.AppendString(2, bucket.Org)
|
_ = b.AppendString(2, bucket.OrgID.String())
|
||||||
_ = b.AppendString(3, bucket.OrganizationID.String())
|
_ = b.AppendString(3, bucket.RetentionPolicyName)
|
||||||
_ = b.AppendString(4, bucket.RetentionPolicyName)
|
_ = b.AppendInt(4, bucket.RetentionPeriod.Nanoseconds())
|
||||||
_ = b.AppendInt(5, bucket.RetentionPeriod.Nanoseconds())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return b.Table()
|
return b.Table()
|
||||||
|
|
|
@ -202,7 +202,7 @@ func testFlux(t testing.TB, l *launcher.TestLauncher, pkg *ast.Package) {
|
||||||
// Query server to ensure write persists.
|
// Query server to ensure write persists.
|
||||||
|
|
||||||
b := &platform.Bucket{
|
b := &platform.Bucket{
|
||||||
Org: "ORG",
|
OrgID: l.Org.ID,
|
||||||
Name: t.Name(),
|
Name: t.Name(),
|
||||||
RetentionPeriod: 0,
|
RetentionPeriod: 0,
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,7 @@ func testFlux(t testing.TB, l *launcher.TestLauncher, pkg *ast.Package) {
|
||||||
orgOpt := &ast.OptionStatement{
|
orgOpt := &ast.OptionStatement{
|
||||||
Assignment: &ast.VariableAssignment{
|
Assignment: &ast.VariableAssignment{
|
||||||
ID: &ast.Identifier{Name: "org"},
|
ID: &ast.Identifier{Name: "org"},
|
||||||
Init: &ast.StringLiteral{Value: b.Org},
|
Init: &ast.StringLiteral{Value: l.Org.Name},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
options := optionsAST.Copy().(*ast.File)
|
options := optionsAST.Copy().(*ast.File)
|
||||||
|
|
|
@ -102,7 +102,7 @@ func (s *BucketService) DeleteBucket(ctx context.Context, bucketID platform.ID)
|
||||||
// The data is dropped first from the storage engine. If this fails for any
|
// The data is dropped first from the storage engine. If this fails for any
|
||||||
// reason, then the bucket will still be available in the future to retrieve
|
// reason, then the bucket will still be available in the future to retrieve
|
||||||
// the orgID, which is needed for the engine.
|
// the orgID, which is needed for the engine.
|
||||||
if err := s.engine.DeleteBucket(bucket.OrganizationID, bucketID); err != nil {
|
if err := s.engine.DeleteBucket(bucket.OrgID, bucketID); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return s.inner.DeleteBucket(ctx, bucketID)
|
return s.inner.DeleteBucket(ctx, bucketID)
|
||||||
|
|
|
@ -33,7 +33,7 @@ func TestBucketService(t *testing.T) {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
bucket := &platform.Bucket{OrganizationID: org.ID}
|
bucket := &platform.Bucket{OrgID: org.ID}
|
||||||
if err := inmemService.CreateBucket(context.TODO(), bucket); err != nil {
|
if err := inmemService.CreateBucket(context.TODO(), bucket); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,14 +113,14 @@ func (s *retentionEnforcer) expireData(buckets []*influxdb.Bucket, now time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
max := now.Add(-b.RetentionPeriod).UnixNano()
|
max := now.Add(-b.RetentionPeriod).UnixNano()
|
||||||
err := s.Engine.DeleteBucketRange(b.OrganizationID, b.ID, math.MinInt64, max)
|
err := s.Engine.DeleteBucketRange(b.OrgID, b.ID, math.MinInt64, max)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Info("unable to delete bucket range",
|
logger.Info("unable to delete bucket range",
|
||||||
zap.String("bucket id", b.ID.String()),
|
zap.String("bucket id", b.ID.String()),
|
||||||
zap.String("org id", b.OrganizationID.String()),
|
zap.String("org id", b.OrgID.String()),
|
||||||
zap.Error(err))
|
zap.Error(err))
|
||||||
}
|
}
|
||||||
s.tracker.IncChecks(b.OrganizationID, b.ID, err == nil)
|
s.tracker.IncChecks(b.OrgID, b.ID, err == nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ func TestRetentionService(t *testing.T) {
|
||||||
// to not delete because no rp, and 1/3rd into the set to not delete because 0 rp.
|
// to not delete because no rp, and 1/3rd into the set to not delete because 0 rp.
|
||||||
if i%3 == 0 {
|
if i%3 == 0 {
|
||||||
buckets = append(buckets, &influxdb.Bucket{
|
buckets = append(buckets, &influxdb.Bucket{
|
||||||
OrganizationID: orgID,
|
OrgID: orgID,
|
||||||
ID: bucketID,
|
ID: bucketID,
|
||||||
RetentionPeriod: 3 * time.Hour,
|
RetentionPeriod: 3 * time.Hour,
|
||||||
})
|
})
|
||||||
|
@ -48,7 +48,7 @@ func TestRetentionService(t *testing.T) {
|
||||||
expRejected[string(name)] = struct{}{}
|
expRejected[string(name)] = struct{}{}
|
||||||
} else if i%3 == 2 {
|
} else if i%3 == 2 {
|
||||||
buckets = append(buckets, &influxdb.Bucket{
|
buckets = append(buckets, &influxdb.Bucket{
|
||||||
OrganizationID: orgID,
|
OrgID: orgID,
|
||||||
ID: bucketID,
|
ID: bucketID,
|
||||||
RetentionPeriod: 0,
|
RetentionPeriod: 0,
|
||||||
})
|
})
|
||||||
|
|
|
@ -119,7 +119,7 @@ func CreateBucket(
|
||||||
args: args{
|
args: args{
|
||||||
bucket: &platform.Bucket{
|
bucket: &platform.Bucket{
|
||||||
Name: "name1",
|
Name: "name1",
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wants: wants{
|
wants: wants{
|
||||||
|
@ -127,8 +127,7 @@ func CreateBucket(
|
||||||
{
|
{
|
||||||
Name: "name1",
|
Name: "name1",
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Org: "theorg",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -145,7 +144,7 @@ func CreateBucket(
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
Name: "bucket1",
|
Name: "bucket1",
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Organizations: []*platform.Organization{
|
Organizations: []*platform.Organization{
|
||||||
|
@ -162,7 +161,7 @@ func CreateBucket(
|
||||||
args: args{
|
args: args{
|
||||||
bucket: &platform.Bucket{
|
bucket: &platform.Bucket{
|
||||||
Name: "bucket2",
|
Name: "bucket2",
|
||||||
OrganizationID: MustIDBase16(orgTwoID),
|
OrgID: MustIDBase16(orgTwoID),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wants: wants{
|
wants: wants{
|
||||||
|
@ -170,63 +169,12 @@ func CreateBucket(
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
Name: "bucket1",
|
Name: "bucket1",
|
||||||
Org: "theorg",
|
OrgID: MustIDBase16(orgOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketTwoID),
|
ID: MustIDBase16(bucketTwoID),
|
||||||
Name: "bucket2",
|
Name: "bucket2",
|
||||||
Org: "otherorg",
|
OrgID: MustIDBase16(orgTwoID),
|
||||||
OrganizationID: MustIDBase16(orgTwoID),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "basic create bucket using org name",
|
|
||||||
fields: BucketFields{
|
|
||||||
IDGenerator: &mock.IDGenerator{
|
|
||||||
IDFn: func() platform.ID {
|
|
||||||
return MustIDBase16(bucketTwoID)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Buckets: []*platform.Bucket{
|
|
||||||
{
|
|
||||||
ID: MustIDBase16(bucketOneID),
|
|
||||||
Name: "bucket1",
|
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Organizations: []*platform.Organization{
|
|
||||||
{
|
|
||||||
Name: "theorg",
|
|
||||||
ID: MustIDBase16(orgOneID),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "otherorg",
|
|
||||||
ID: MustIDBase16(orgTwoID),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
args: args{
|
|
||||||
bucket: &platform.Bucket{
|
|
||||||
Name: "bucket2",
|
|
||||||
Org: "otherorg",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
wants: wants{
|
|
||||||
buckets: []*platform.Bucket{
|
|
||||||
{
|
|
||||||
ID: MustIDBase16(bucketOneID),
|
|
||||||
Name: "bucket1",
|
|
||||||
Org: "theorg",
|
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ID: MustIDBase16(bucketTwoID),
|
|
||||||
Name: "bucket2",
|
|
||||||
Org: "otherorg",
|
|
||||||
OrganizationID: MustIDBase16(orgTwoID),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -243,7 +191,7 @@ func CreateBucket(
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
Name: "bucket1",
|
Name: "bucket1",
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Organizations: []*platform.Organization{
|
Organizations: []*platform.Organization{
|
||||||
|
@ -260,7 +208,7 @@ func CreateBucket(
|
||||||
args: args{
|
args: args{
|
||||||
bucket: &platform.Bucket{
|
bucket: &platform.Bucket{
|
||||||
Name: "bucket1",
|
Name: "bucket1",
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wants: wants{
|
wants: wants{
|
||||||
|
@ -268,8 +216,7 @@ func CreateBucket(
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
Name: "bucket1",
|
Name: "bucket1",
|
||||||
Org: "theorg",
|
OrgID: MustIDBase16(orgOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
err: &platform.Error{
|
err: &platform.Error{
|
||||||
|
@ -301,14 +248,14 @@ func CreateBucket(
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
Name: "bucket1",
|
Name: "bucket1",
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
args: args{
|
args: args{
|
||||||
bucket: &platform.Bucket{
|
bucket: &platform.Bucket{
|
||||||
Name: "bucket1",
|
Name: "bucket1",
|
||||||
OrganizationID: MustIDBase16(orgTwoID),
|
OrgID: MustIDBase16(orgTwoID),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wants: wants{
|
wants: wants{
|
||||||
|
@ -316,14 +263,12 @@ func CreateBucket(
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
Name: "bucket1",
|
Name: "bucket1",
|
||||||
Org: "theorg",
|
OrgID: MustIDBase16(orgOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketTwoID),
|
ID: MustIDBase16(bucketTwoID),
|
||||||
Name: "bucket1",
|
Name: "bucket1",
|
||||||
Org: "otherorg",
|
OrgID: MustIDBase16(orgTwoID),
|
||||||
OrganizationID: MustIDBase16(orgTwoID),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -338,7 +283,7 @@ func CreateBucket(
|
||||||
args: args{
|
args: args{
|
||||||
bucket: &platform.Bucket{
|
bucket: &platform.Bucket{
|
||||||
Name: "name1",
|
Name: "name1",
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wants: wants{
|
wants: wants{
|
||||||
|
@ -350,28 +295,6 @@ func CreateBucket(
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "create bucket with org name not exist",
|
|
||||||
fields: BucketFields{
|
|
||||||
IDGenerator: mock.NewIDGenerator(bucketOneID, t),
|
|
||||||
Buckets: []*platform.Bucket{},
|
|
||||||
Organizations: []*platform.Organization{},
|
|
||||||
},
|
|
||||||
args: args{
|
|
||||||
bucket: &platform.Bucket{
|
|
||||||
Name: "name1",
|
|
||||||
Org: "org1",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
wants: wants{
|
|
||||||
buckets: []*platform.Bucket{},
|
|
||||||
err: &platform.Error{
|
|
||||||
Code: platform.ENotFound,
|
|
||||||
Msg: "organization name \"org1\" not found",
|
|
||||||
Op: platform.OpCreateBucket,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
@ -423,12 +346,12 @@ func FindBucketByID(
|
||||||
Buckets: []*platform.Bucket{
|
Buckets: []*platform.Bucket{
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "bucket1",
|
Name: "bucket1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketTwoID),
|
ID: MustIDBase16(bucketTwoID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "bucket2",
|
Name: "bucket2",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -445,8 +368,7 @@ func FindBucketByID(
|
||||||
wants: wants{
|
wants: wants{
|
||||||
bucket: &platform.Bucket{
|
bucket: &platform.Bucket{
|
||||||
ID: MustIDBase16(bucketTwoID),
|
ID: MustIDBase16(bucketTwoID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Org: "theorg",
|
|
||||||
Name: "bucket2",
|
Name: "bucket2",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -457,12 +379,12 @@ func FindBucketByID(
|
||||||
Buckets: []*platform.Bucket{
|
Buckets: []*platform.Bucket{
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "bucket1",
|
Name: "bucket1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketTwoID),
|
ID: MustIDBase16(bucketTwoID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "bucket2",
|
Name: "bucket2",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -541,12 +463,12 @@ func FindBuckets(
|
||||||
Buckets: []*platform.Bucket{
|
Buckets: []*platform.Bucket{
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "abc",
|
Name: "abc",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketTwoID),
|
ID: MustIDBase16(bucketTwoID),
|
||||||
OrganizationID: MustIDBase16(orgTwoID),
|
OrgID: MustIDBase16(orgTwoID),
|
||||||
Name: "xyz",
|
Name: "xyz",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -556,14 +478,12 @@ func FindBuckets(
|
||||||
buckets: []*platform.Bucket{
|
buckets: []*platform.Bucket{
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Org: "theorg",
|
|
||||||
Name: "abc",
|
Name: "abc",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketTwoID),
|
ID: MustIDBase16(bucketTwoID),
|
||||||
OrganizationID: MustIDBase16(orgTwoID),
|
OrgID: MustIDBase16(orgTwoID),
|
||||||
Org: "otherorg",
|
|
||||||
Name: "xyz",
|
Name: "xyz",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -581,17 +501,17 @@ func FindBuckets(
|
||||||
Buckets: []*platform.Bucket{
|
Buckets: []*platform.Bucket{
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "abc",
|
Name: "abc",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketTwoID),
|
ID: MustIDBase16(bucketTwoID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "def",
|
Name: "def",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketThreeID),
|
ID: MustIDBase16(bucketThreeID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "xyz",
|
Name: "xyz",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -606,8 +526,7 @@ func FindBuckets(
|
||||||
buckets: []*platform.Bucket{
|
buckets: []*platform.Bucket{
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketTwoID),
|
ID: MustIDBase16(bucketTwoID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Org: "theorg",
|
|
||||||
Name: "def",
|
Name: "def",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -625,17 +544,17 @@ func FindBuckets(
|
||||||
Buckets: []*platform.Bucket{
|
Buckets: []*platform.Bucket{
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "abc",
|
Name: "abc",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketTwoID),
|
ID: MustIDBase16(bucketTwoID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "def",
|
Name: "def",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketThreeID),
|
ID: MustIDBase16(bucketThreeID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "xyz",
|
Name: "xyz",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -650,14 +569,12 @@ func FindBuckets(
|
||||||
buckets: []*platform.Bucket{
|
buckets: []*platform.Bucket{
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketTwoID),
|
ID: MustIDBase16(bucketTwoID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Org: "theorg",
|
|
||||||
Name: "def",
|
Name: "def",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Org: "theorg",
|
|
||||||
Name: "abc",
|
Name: "abc",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -679,17 +596,17 @@ func FindBuckets(
|
||||||
Buckets: []*platform.Bucket{
|
Buckets: []*platform.Bucket{
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "abc",
|
Name: "abc",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketTwoID),
|
ID: MustIDBase16(bucketTwoID),
|
||||||
OrganizationID: MustIDBase16(orgTwoID),
|
OrgID: MustIDBase16(orgTwoID),
|
||||||
Name: "xyz",
|
Name: "xyz",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketThreeID),
|
ID: MustIDBase16(bucketThreeID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "123",
|
Name: "123",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -701,14 +618,12 @@ func FindBuckets(
|
||||||
buckets: []*platform.Bucket{
|
buckets: []*platform.Bucket{
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Org: "theorg",
|
|
||||||
Name: "abc",
|
Name: "abc",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketThreeID),
|
ID: MustIDBase16(bucketThreeID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Org: "theorg",
|
|
||||||
Name: "123",
|
Name: "123",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -730,17 +645,17 @@ func FindBuckets(
|
||||||
Buckets: []*platform.Bucket{
|
Buckets: []*platform.Bucket{
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "abc",
|
Name: "abc",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketTwoID),
|
ID: MustIDBase16(bucketTwoID),
|
||||||
OrganizationID: MustIDBase16(orgTwoID),
|
OrgID: MustIDBase16(orgTwoID),
|
||||||
Name: "xyz",
|
Name: "xyz",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketThreeID),
|
ID: MustIDBase16(bucketThreeID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "123",
|
Name: "123",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -752,14 +667,12 @@ func FindBuckets(
|
||||||
buckets: []*platform.Bucket{
|
buckets: []*platform.Bucket{
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Org: "theorg",
|
|
||||||
Name: "abc",
|
Name: "abc",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketThreeID),
|
ID: MustIDBase16(bucketThreeID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Org: "theorg",
|
|
||||||
Name: "123",
|
Name: "123",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -777,12 +690,12 @@ func FindBuckets(
|
||||||
Buckets: []*platform.Bucket{
|
Buckets: []*platform.Bucket{
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "abc",
|
Name: "abc",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketTwoID),
|
ID: MustIDBase16(bucketTwoID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "xyz",
|
Name: "xyz",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -794,8 +707,7 @@ func FindBuckets(
|
||||||
buckets: []*platform.Bucket{
|
buckets: []*platform.Bucket{
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketTwoID),
|
ID: MustIDBase16(bucketTwoID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Org: "theorg",
|
|
||||||
Name: "xyz",
|
Name: "xyz",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -881,12 +793,12 @@ func DeleteBucket(
|
||||||
{
|
{
|
||||||
Name: "A",
|
Name: "A",
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "B",
|
Name: "B",
|
||||||
ID: MustIDBase16(bucketThreeID),
|
ID: MustIDBase16(bucketThreeID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -898,8 +810,7 @@ func DeleteBucket(
|
||||||
{
|
{
|
||||||
Name: "B",
|
Name: "B",
|
||||||
ID: MustIDBase16(bucketThreeID),
|
ID: MustIDBase16(bucketThreeID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Org: "theorg",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -917,12 +828,12 @@ func DeleteBucket(
|
||||||
{
|
{
|
||||||
Name: "A",
|
Name: "A",
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "B",
|
Name: "B",
|
||||||
ID: MustIDBase16(bucketThreeID),
|
ID: MustIDBase16(bucketThreeID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -939,14 +850,12 @@ func DeleteBucket(
|
||||||
{
|
{
|
||||||
Name: "A",
|
Name: "A",
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Org: "theorg",
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "B",
|
Name: "B",
|
||||||
ID: MustIDBase16(bucketThreeID),
|
ID: MustIDBase16(bucketThreeID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Org: "theorg",
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1006,12 +915,12 @@ func FindBucket(
|
||||||
Buckets: []*platform.Bucket{
|
Buckets: []*platform.Bucket{
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "abc",
|
Name: "abc",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketTwoID),
|
ID: MustIDBase16(bucketTwoID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "xyz",
|
Name: "xyz",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1023,8 +932,7 @@ func FindBucket(
|
||||||
wants: wants{
|
wants: wants{
|
||||||
bucket: &platform.Bucket{
|
bucket: &platform.Bucket{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Org: "theorg",
|
|
||||||
Name: "abc",
|
Name: "abc",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1110,12 +1018,12 @@ func UpdateBucket(
|
||||||
Buckets: []*platform.Bucket{
|
Buckets: []*platform.Bucket{
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "bucket1",
|
Name: "bucket1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketTwoID),
|
ID: MustIDBase16(bucketTwoID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "bucket2",
|
Name: "bucket2",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1127,8 +1035,7 @@ func UpdateBucket(
|
||||||
wants: wants{
|
wants: wants{
|
||||||
bucket: &platform.Bucket{
|
bucket: &platform.Bucket{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Org: "theorg",
|
|
||||||
Name: "changed",
|
Name: "changed",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1145,12 +1052,12 @@ func UpdateBucket(
|
||||||
Buckets: []*platform.Bucket{
|
Buckets: []*platform.Bucket{
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "bucket1",
|
Name: "bucket1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketTwoID),
|
ID: MustIDBase16(bucketTwoID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "bucket2",
|
Name: "bucket2",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1178,12 +1085,12 @@ func UpdateBucket(
|
||||||
Buckets: []*platform.Bucket{
|
Buckets: []*platform.Bucket{
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "bucket1",
|
Name: "bucket1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketTwoID),
|
ID: MustIDBase16(bucketTwoID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "bucket2",
|
Name: "bucket2",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1195,8 +1102,7 @@ func UpdateBucket(
|
||||||
wants: wants{
|
wants: wants{
|
||||||
bucket: &platform.Bucket{
|
bucket: &platform.Bucket{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Org: "theorg",
|
|
||||||
Name: "bucket1",
|
Name: "bucket1",
|
||||||
RetentionPeriod: 100 * time.Minute,
|
RetentionPeriod: 100 * time.Minute,
|
||||||
},
|
},
|
||||||
|
@ -1214,12 +1120,12 @@ func UpdateBucket(
|
||||||
Buckets: []*platform.Bucket{
|
Buckets: []*platform.Bucket{
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "bucket1",
|
Name: "bucket1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketTwoID),
|
ID: MustIDBase16(bucketTwoID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "bucket2",
|
Name: "bucket2",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1232,8 +1138,7 @@ func UpdateBucket(
|
||||||
wants: wants{
|
wants: wants{
|
||||||
bucket: &platform.Bucket{
|
bucket: &platform.Bucket{
|
||||||
ID: MustIDBase16(bucketTwoID),
|
ID: MustIDBase16(bucketTwoID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Org: "theorg",
|
|
||||||
Name: "changed",
|
Name: "changed",
|
||||||
RetentionPeriod: 101 * time.Minute,
|
RetentionPeriod: 101 * time.Minute,
|
||||||
},
|
},
|
||||||
|
@ -1251,12 +1156,12 @@ func UpdateBucket(
|
||||||
Buckets: []*platform.Bucket{
|
Buckets: []*platform.Bucket{
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "bucket1",
|
Name: "bucket1",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: MustIDBase16(bucketTwoID),
|
ID: MustIDBase16(bucketTwoID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Name: "bucket2",
|
Name: "bucket2",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1269,8 +1174,7 @@ func UpdateBucket(
|
||||||
wants: wants{
|
wants: wants{
|
||||||
bucket: &platform.Bucket{
|
bucket: &platform.Bucket{
|
||||||
ID: MustIDBase16(bucketTwoID),
|
ID: MustIDBase16(bucketTwoID),
|
||||||
OrganizationID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
Org: "theorg",
|
|
||||||
Name: "bucket2",
|
Name: "bucket2",
|
||||||
RetentionPeriod: 101 * time.Minute,
|
RetentionPeriod: 101 * time.Minute,
|
||||||
},
|
},
|
||||||
|
|
|
@ -159,8 +159,7 @@ func Generate(
|
||||||
Bucket: &platform.Bucket{
|
Bucket: &platform.Bucket{
|
||||||
ID: MustIDBase16(threeID),
|
ID: MustIDBase16(threeID),
|
||||||
Name: "bucket1",
|
Name: "bucket1",
|
||||||
Org: "org1",
|
OrgID: MustIDBase16(twoID),
|
||||||
OrganizationID: MustIDBase16(twoID),
|
|
||||||
RetentionPeriod: time.Hour * 24 * 7,
|
RetentionPeriod: time.Hour * 24 * 7,
|
||||||
},
|
},
|
||||||
Auth: &platform.Authorization{
|
Auth: &platform.Authorization{
|
||||||
|
|
Loading…
Reference in New Issue