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
|
||||
}
|
||||
|
||||
if err := authorizeReadBucket(ctx, b.OrganizationID, id); err != nil {
|
||||
if err := authorizeReadBucket(ctx, b.OrgID, id); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ func (s *BucketService) FindBucket(ctx context.Context, filter influxdb.BucketFi
|
|||
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
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ func (s *BucketService) FindBuckets(ctx context.Context, filter influxdb.BucketF
|
|||
// https://github.com/golang/go/wiki/SliceTricks#filtering-without-allocating
|
||||
buckets := bs[:0]
|
||||
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 {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ func (s *BucketService) CreateBucket(ctx context.Context, b *influxdb.Bucket) er
|
|||
span, ctx := tracing.StartSpanFromContext(ctx)
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ func (s *BucketService) UpdateBucket(ctx context.Context, id influxdb.ID, upd in
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if err := authorizeWriteBucket(ctx, b.OrganizationID, id); err != nil {
|
||||
if err := authorizeWriteBucket(ctx, b.OrgID, id); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ func (s *BucketService) DeleteBucket(ctx context.Context, id influxdb.ID) error
|
|||
return err
|
||||
}
|
||||
|
||||
if err := authorizeWriteBucket(ctx, b.OrganizationID, id); err != nil {
|
||||
if err := authorizeWriteBucket(ctx, b.OrgID, id); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
|
|
@ -51,8 +51,8 @@ func TestBucketService_FindBucketByID(t *testing.T) {
|
|||
BucketService: &mock.BucketService{
|
||||
FindBucketByIDFn: func(ctx context.Context, id influxdb.ID) (*influxdb.Bucket, error) {
|
||||
return &influxdb.Bucket{
|
||||
ID: id,
|
||||
OrganizationID: 10,
|
||||
ID: id,
|
||||
OrgID: 10,
|
||||
}, nil
|
||||
},
|
||||
},
|
||||
|
@ -77,8 +77,8 @@ func TestBucketService_FindBucketByID(t *testing.T) {
|
|||
BucketService: &mock.BucketService{
|
||||
FindBucketByIDFn: func(ctx context.Context, id influxdb.ID) (*influxdb.Bucket, error) {
|
||||
return &influxdb.Bucket{
|
||||
ID: id,
|
||||
OrganizationID: 10,
|
||||
ID: id,
|
||||
OrgID: 10,
|
||||
}, nil
|
||||
},
|
||||
},
|
||||
|
@ -138,8 +138,8 @@ func TestBucketService_FindBucket(t *testing.T) {
|
|||
BucketService: &mock.BucketService{
|
||||
FindBucketFn: func(ctx context.Context, filter influxdb.BucketFilter) (*influxdb.Bucket, error) {
|
||||
return &influxdb.Bucket{
|
||||
ID: 1,
|
||||
OrganizationID: 10,
|
||||
ID: 1,
|
||||
OrgID: 10,
|
||||
}, nil
|
||||
},
|
||||
},
|
||||
|
@ -163,8 +163,8 @@ func TestBucketService_FindBucket(t *testing.T) {
|
|||
BucketService: &mock.BucketService{
|
||||
FindBucketFn: func(ctx context.Context, filter influxdb.BucketFilter) (*influxdb.Bucket, error) {
|
||||
return &influxdb.Bucket{
|
||||
ID: 1,
|
||||
OrganizationID: 10,
|
||||
ID: 1,
|
||||
OrgID: 10,
|
||||
}, nil
|
||||
},
|
||||
},
|
||||
|
@ -225,16 +225,16 @@ func TestBucketService_FindBuckets(t *testing.T) {
|
|||
FindBucketsFn: func(ctx context.Context, filter influxdb.BucketFilter, opt ...influxdb.FindOptions) ([]*influxdb.Bucket, int, error) {
|
||||
return []*influxdb.Bucket{
|
||||
{
|
||||
ID: 1,
|
||||
OrganizationID: 10,
|
||||
ID: 1,
|
||||
OrgID: 10,
|
||||
},
|
||||
{
|
||||
ID: 2,
|
||||
OrganizationID: 10,
|
||||
ID: 2,
|
||||
OrgID: 10,
|
||||
},
|
||||
{
|
||||
ID: 3,
|
||||
OrganizationID: 11,
|
||||
ID: 3,
|
||||
OrgID: 11,
|
||||
},
|
||||
}, 3, nil
|
||||
},
|
||||
|
@ -251,16 +251,16 @@ func TestBucketService_FindBuckets(t *testing.T) {
|
|||
wants: wants{
|
||||
buckets: []*influxdb.Bucket{
|
||||
{
|
||||
ID: 1,
|
||||
OrganizationID: 10,
|
||||
ID: 1,
|
||||
OrgID: 10,
|
||||
},
|
||||
{
|
||||
ID: 2,
|
||||
OrganizationID: 10,
|
||||
ID: 2,
|
||||
OrgID: 10,
|
||||
},
|
||||
{
|
||||
ID: 3,
|
||||
OrganizationID: 11,
|
||||
ID: 3,
|
||||
OrgID: 11,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -273,16 +273,16 @@ func TestBucketService_FindBuckets(t *testing.T) {
|
|||
FindBucketsFn: func(ctx context.Context, filter influxdb.BucketFilter, opt ...influxdb.FindOptions) ([]*influxdb.Bucket, int, error) {
|
||||
return []*influxdb.Bucket{
|
||||
{
|
||||
ID: 1,
|
||||
OrganizationID: 10,
|
||||
ID: 1,
|
||||
OrgID: 10,
|
||||
},
|
||||
{
|
||||
ID: 2,
|
||||
OrganizationID: 10,
|
||||
ID: 2,
|
||||
OrgID: 10,
|
||||
},
|
||||
{
|
||||
ID: 3,
|
||||
OrganizationID: 11,
|
||||
ID: 3,
|
||||
OrgID: 11,
|
||||
},
|
||||
}, 3, nil
|
||||
},
|
||||
|
@ -300,12 +300,12 @@ func TestBucketService_FindBuckets(t *testing.T) {
|
|||
wants: wants{
|
||||
buckets: []*influxdb.Bucket{
|
||||
{
|
||||
ID: 1,
|
||||
OrganizationID: 10,
|
||||
ID: 1,
|
||||
OrgID: 10,
|
||||
},
|
||||
{
|
||||
ID: 2,
|
||||
OrganizationID: 10,
|
||||
ID: 2,
|
||||
OrgID: 10,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -353,14 +353,14 @@ func TestBucketService_UpdateBucket(t *testing.T) {
|
|||
BucketService: &mock.BucketService{
|
||||
FindBucketByIDFn: func(ctc context.Context, id influxdb.ID) (*influxdb.Bucket, error) {
|
||||
return &influxdb.Bucket{
|
||||
ID: 1,
|
||||
OrganizationID: 10,
|
||||
ID: 1,
|
||||
OrgID: 10,
|
||||
}, nil
|
||||
},
|
||||
UpdateBucketFn: func(ctx context.Context, id influxdb.ID, upd influxdb.BucketUpdate) (*influxdb.Bucket, error) {
|
||||
return &influxdb.Bucket{
|
||||
ID: 1,
|
||||
OrganizationID: 10,
|
||||
ID: 1,
|
||||
OrgID: 10,
|
||||
}, nil
|
||||
},
|
||||
},
|
||||
|
@ -394,14 +394,14 @@ func TestBucketService_UpdateBucket(t *testing.T) {
|
|||
BucketService: &mock.BucketService{
|
||||
FindBucketByIDFn: func(ctc context.Context, id influxdb.ID) (*influxdb.Bucket, error) {
|
||||
return &influxdb.Bucket{
|
||||
ID: 1,
|
||||
OrganizationID: 10,
|
||||
ID: 1,
|
||||
OrgID: 10,
|
||||
}, nil
|
||||
},
|
||||
UpdateBucketFn: func(ctx context.Context, id influxdb.ID, upd influxdb.BucketUpdate) (*influxdb.Bucket, error) {
|
||||
return &influxdb.Bucket{
|
||||
ID: 1,
|
||||
OrganizationID: 10,
|
||||
ID: 1,
|
||||
OrgID: 10,
|
||||
}, nil
|
||||
},
|
||||
},
|
||||
|
@ -464,8 +464,8 @@ func TestBucketService_DeleteBucket(t *testing.T) {
|
|||
BucketService: &mock.BucketService{
|
||||
FindBucketByIDFn: func(ctc context.Context, id influxdb.ID) (*influxdb.Bucket, error) {
|
||||
return &influxdb.Bucket{
|
||||
ID: 1,
|
||||
OrganizationID: 10,
|
||||
ID: 1,
|
||||
OrgID: 10,
|
||||
}, nil
|
||||
},
|
||||
DeleteBucketFn: func(ctx context.Context, id influxdb.ID) error {
|
||||
|
@ -502,8 +502,8 @@ func TestBucketService_DeleteBucket(t *testing.T) {
|
|||
BucketService: &mock.BucketService{
|
||||
FindBucketByIDFn: func(ctc context.Context, id influxdb.ID) (*influxdb.Bucket, error) {
|
||||
return &influxdb.Bucket{
|
||||
ID: 1,
|
||||
OrganizationID: 10,
|
||||
ID: 1,
|
||||
OrgID: 10,
|
||||
}, nil
|
||||
},
|
||||
DeleteBucketFn: func(ctx context.Context, id influxdb.ID) error {
|
||||
|
@ -621,7 +621,7 @@ func TestBucketService_CreateBucket(t *testing.T) {
|
|||
ctx := context.Background()
|
||||
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)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -30,20 +30,6 @@ func (c *Client) initializeBuckets(ctx context.Context, tx *bolt.Tx) error {
|
|||
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.
|
||||
func (c *Client) FindBucketByID(ctx context.Context, id platform.ID) (*platform.Bucket, error) {
|
||||
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) {
|
||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
||||
span, _ := tracing.StartSpanFromContext(ctx)
|
||||
defer span.Finish()
|
||||
|
||||
var b platform.Bucket
|
||||
|
@ -97,13 +83,6 @@ func (c *Client) findBucketByID(ctx context.Context, tx *bolt.Tx, id platform.ID
|
|||
Err: err,
|
||||
}
|
||||
}
|
||||
|
||||
if err := c.setOrganizationOnBucket(ctx, tx, &b); err != nil {
|
||||
return nil, &platform.Error{
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
|
||||
return &b, nil
|
||||
}
|
||||
|
||||
|
@ -135,8 +114,8 @@ func (c *Client) findBucketByName(ctx context.Context, tx *bolt.Tx, orgID platfo
|
|||
defer span.Finish()
|
||||
|
||||
b := &platform.Bucket{
|
||||
OrganizationID: orgID,
|
||||
Name: n,
|
||||
OrgID: orgID,
|
||||
Name: n,
|
||||
}
|
||||
key, err := bucketIndexKey(b)
|
||||
if err != nil {
|
||||
|
@ -233,7 +212,7 @@ func filterBucketsFn(filter platform.BucketFilter) func(b *platform.Bucket) bool
|
|||
|
||||
if filter.Name != nil && filter.OrganizationID != nil {
|
||||
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 {
|
||||
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
|
||||
op := getOp(platform.OpCreateBucket)
|
||||
return c.db.Update(func(tx *bolt.Tx) error {
|
||||
if b.OrganizationID.Valid() {
|
||||
_, pe := c.findOrganizationByID(ctx, tx, b.OrganizationID)
|
||||
if b.OrgID.Valid() {
|
||||
_, pe := c.findOrganizationByID(ctx, tx, b.OrgID)
|
||||
if pe != nil {
|
||||
return &platform.Error{
|
||||
Err: pe,
|
||||
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)
|
||||
|
@ -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 {
|
||||
ms, err := c.findUserResourceMappings(ctx, tx, platform.UserResourceMappingFilter{
|
||||
ResourceType: platform.OrgsResourceType,
|
||||
ResourceID: b.OrganizationID,
|
||||
ResourceID: b.OrgID,
|
||||
})
|
||||
if err != nil {
|
||||
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 {
|
||||
b.Org = ""
|
||||
v, err := json.Marshal(b)
|
||||
if err != nil {
|
||||
return &platform.Error{
|
||||
|
@ -471,11 +440,11 @@ func (c *Client) putBucket(ctx context.Context, tx *bolt.Tx, b *platform.Bucket)
|
|||
Err: err,
|
||||
}
|
||||
}
|
||||
return c.setOrganizationOnBucket(ctx, tx, b)
|
||||
return nil
|
||||
}
|
||||
|
||||
func bucketIndexKey(b *platform.Bucket) ([]byte, *platform.Error) {
|
||||
orgID, err := b.OrganizationID.Encode()
|
||||
orgID, err := b.OrgID.Encode()
|
||||
if err != nil {
|
||||
return nil, &platform.Error{
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
if err := c.setOrganizationOnBucket(ctx, tx, b); err != nil {
|
||||
return err
|
||||
}
|
||||
if !fn(b) {
|
||||
break
|
||||
}
|
||||
|
@ -556,7 +522,7 @@ func (c *Client) updateBucket(ctx context.Context, tx *bolt.Tx, id platform.ID,
|
|||
}
|
||||
|
||||
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 {
|
||||
return nil, &platform.Error{
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := c.setOrganizationOnBucket(ctx, tx, b); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return b, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -78,8 +78,8 @@ func TestClient_Name(t *testing.T) {
|
|||
Name: "o1",
|
||||
})
|
||||
return s.CreateBucket(ctx, &platform.Bucket{
|
||||
Name: "b1",
|
||||
OrganizationID: testID,
|
||||
Name: "b1",
|
||||
OrgID: testID,
|
||||
})
|
||||
},
|
||||
},
|
||||
|
|
|
@ -102,8 +102,7 @@ func (c *Client) Generate(ctx context.Context, req *platform.OnboardingRequest)
|
|||
}
|
||||
bucket := &platform.Bucket{
|
||||
Name: req.Bucket,
|
||||
Org: o.Name,
|
||||
OrganizationID: o.ID,
|
||||
OrgID: o.ID,
|
||||
RetentionPeriod: time.Duration(req.RetentionPeriod) * time.Hour,
|
||||
}
|
||||
if err = c.CreateBucket(ctx, bucket); err != nil {
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/coreos/bbolt"
|
||||
bolt "github.com/coreos/bbolt"
|
||||
"github.com/influxdata/influxdb"
|
||||
influxdbcontext "github.com/influxdata/influxdb/context"
|
||||
"github.com/influxdata/influxdb/kit/tracing"
|
||||
|
@ -507,7 +507,7 @@ func (c *Client) FindResourceOrganizationID(ctx context.Context, rt influxdb.Res
|
|||
if err != nil {
|
||||
return influxdb.InvalidID(), err
|
||||
}
|
||||
return r.OrganizationID, nil
|
||||
return r.OrgID, nil
|
||||
case influxdb.DashboardsResourceType:
|
||||
r, err := c.FindDashboardByID(ctx, id)
|
||||
if err != nil {
|
||||
|
|
|
@ -21,8 +21,7 @@ const InfiniteRetention = 0
|
|||
// Bucket is a bucket. 🎉
|
||||
type Bucket struct {
|
||||
ID ID `json:"id,omitempty"`
|
||||
OrganizationID ID `json:"orgID,omitempty"`
|
||||
Org string `json:"org,omitempty"`
|
||||
OrgID ID `json:"orgID,omitempty"`
|
||||
Name string `json:"name"`
|
||||
RetentionPolicyName string `json:"rp,omitempty"` // This to support v1 sources
|
||||
RetentionPeriod time.Duration `json:"retentionPeriod"`
|
||||
|
|
|
@ -26,7 +26,6 @@ func bucketF(cmd *cobra.Command, args []string) {
|
|||
// BucketCreateFlags define the Create Command
|
||||
type BucketCreateFlags struct {
|
||||
name string
|
||||
org string
|
||||
orgID string
|
||||
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().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.MarkFlagRequired("name")
|
||||
|
||||
|
@ -60,9 +58,8 @@ func newBucketService(f Flags) (platform.BucketService, error) {
|
|||
}
|
||||
|
||||
func bucketCreateF(cmd *cobra.Command, args []string) error {
|
||||
if (bucketCreateFlags.org == "" && bucketCreateFlags.orgID == "") ||
|
||||
(bucketCreateFlags.org != "" && bucketCreateFlags.orgID != "") {
|
||||
return fmt.Errorf("must specify exactly one of org or org-id")
|
||||
if bucketCreateFlags.orgID == "" {
|
||||
return fmt.Errorf("must specify org-id")
|
||||
}
|
||||
|
||||
s, err := newBucketService(flags)
|
||||
|
@ -75,16 +72,12 @@ func bucketCreateF(cmd *cobra.Command, args []string) error {
|
|||
RetentionPeriod: bucketCreateFlags.retention,
|
||||
}
|
||||
|
||||
if bucketCreateFlags.org != "" {
|
||||
b.Org = bucketCreateFlags.org
|
||||
}
|
||||
|
||||
if bucketCreateFlags.orgID != "" {
|
||||
id, err := platform.IDFromString(bucketCreateFlags.orgID)
|
||||
if err != nil {
|
||||
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 {
|
||||
|
@ -100,11 +93,10 @@ func bucketCreateF(cmd *cobra.Command, args []string) error {
|
|||
"OrganizationID",
|
||||
)
|
||||
w.Write(map[string]interface{}{
|
||||
"ID": b.ID.String(),
|
||||
"Name": b.Name,
|
||||
"Retention": b.RetentionPeriod,
|
||||
"Org": b.Org,
|
||||
"OrganizationID": b.OrganizationID.String(),
|
||||
"ID": b.ID.String(),
|
||||
"Name": b.Name,
|
||||
"Retention": b.RetentionPeriod,
|
||||
"OrgID": b.OrgID.String(),
|
||||
})
|
||||
w.Flush()
|
||||
|
||||
|
@ -186,11 +178,10 @@ func bucketFindF(cmd *cobra.Command, args []string) error {
|
|||
)
|
||||
for _, b := range buckets {
|
||||
w.Write(map[string]interface{}{
|
||||
"ID": b.ID.String(),
|
||||
"Name": b.Name,
|
||||
"Retention": b.RetentionPeriod,
|
||||
"Org": b.Org,
|
||||
"OrganizationID": b.OrganizationID.String(),
|
||||
"ID": b.ID.String(),
|
||||
"Name": b.Name,
|
||||
"Retention": b.RetentionPeriod,
|
||||
"OrgID": b.OrgID.String(),
|
||||
})
|
||||
}
|
||||
w.Flush()
|
||||
|
@ -255,11 +246,10 @@ func bucketUpdateF(cmd *cobra.Command, args []string) error {
|
|||
"OrganizationID",
|
||||
)
|
||||
w.Write(map[string]interface{}{
|
||||
"ID": b.ID.String(),
|
||||
"Name": b.Name,
|
||||
"Retention": b.RetentionPeriod,
|
||||
"Org": b.Org,
|
||||
"OrganizationID": b.OrganizationID.String(),
|
||||
"ID": b.ID.String(),
|
||||
"Name": b.Name,
|
||||
"Retention": b.RetentionPeriod,
|
||||
"OrgID": b.OrgID.String(),
|
||||
})
|
||||
w.Flush()
|
||||
|
||||
|
@ -304,12 +294,11 @@ func bucketDeleteF(cmd *cobra.Command, args []string) error {
|
|||
"Deleted",
|
||||
)
|
||||
w.Write(map[string]interface{}{
|
||||
"ID": b.ID.String(),
|
||||
"Name": b.Name,
|
||||
"Retention": b.RetentionPeriod,
|
||||
"Org": b.Org,
|
||||
"OrganizationID": b.OrganizationID.String(),
|
||||
"Deleted": true,
|
||||
"ID": b.ID.String(),
|
||||
"Name": b.Name,
|
||||
"Retention": b.RetentionPeriod,
|
||||
"OrgID": b.OrgID.String(),
|
||||
"Deleted": true,
|
||||
})
|
||||
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
|
||||
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.
|
||||
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 {
|
||||
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 {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -127,8 +127,7 @@ func NewBucketHandler(b *BucketBackend) *BucketHandler {
|
|||
// bucket is used for serialization/deserialization with duration string syntax.
|
||||
type bucket struct {
|
||||
ID influxdb.ID `json:"id,omitempty"`
|
||||
OrganizationID influxdb.ID `json:"organizationID,omitempty"`
|
||||
Org string `json:"org,omitempty"`
|
||||
OrgID influxdb.ID `json:"orgID,omitempty"`
|
||||
Name string `json:"name"`
|
||||
RetentionPolicyName string `json:"rp,omitempty"` // This to support v1 sources
|
||||
RetentionRules []retentionRule `json:"retentionRules"`
|
||||
|
@ -160,8 +159,7 @@ func (b *bucket) toInfluxDB() (*influxdb.Bucket, error) {
|
|||
|
||||
return &influxdb.Bucket{
|
||||
ID: b.ID,
|
||||
OrganizationID: b.OrganizationID,
|
||||
Org: b.Org,
|
||||
OrgID: b.OrgID,
|
||||
Name: b.Name,
|
||||
RetentionPolicyName: b.RetentionPolicyName,
|
||||
RetentionPeriod: d,
|
||||
|
@ -184,8 +182,7 @@ func newBucket(pb *influxdb.Bucket) *bucket {
|
|||
|
||||
return &bucket{
|
||||
ID: pb.ID,
|
||||
OrganizationID: pb.OrganizationID,
|
||||
Org: pb.Org,
|
||||
OrgID: pb.OrgID,
|
||||
Name: pb.Name,
|
||||
RetentionPolicyName: pb.RetentionPolicyName,
|
||||
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),
|
||||
"logs": fmt.Sprintf("/api/v2/buckets/%s/logs", 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),
|
||||
"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),
|
||||
Labels: []influxdb.Label{},
|
||||
|
@ -296,16 +293,6 @@ func (h *BucketHandler) handlePostBucket(w http.ResponseWriter, r *http.Request)
|
|||
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 {
|
||||
EncodeError(ctx, err, w)
|
||||
return
|
||||
|
@ -322,7 +309,7 @@ type postBucketRequest struct {
|
|||
}
|
||||
|
||||
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 nil
|
||||
|
|
|
@ -62,13 +62,13 @@ func TestService_handleGetBuckets(t *testing.T) {
|
|||
{
|
||||
ID: platformtesting.MustIDBase16("0b501e7e557ab1ed"),
|
||||
Name: "hello",
|
||||
OrganizationID: platformtesting.MustIDBase16("50f7ba1150f7ba11"),
|
||||
OrgID: platformtesting.MustIDBase16("50f7ba1150f7ba11"),
|
||||
RetentionPeriod: 2 * time.Second,
|
||||
},
|
||||
{
|
||||
ID: platformtesting.MustIDBase16("c0175f0077a77005"),
|
||||
Name: "example",
|
||||
OrganizationID: platformtesting.MustIDBase16("7e55e118dbabb1ed"),
|
||||
OrgID: platformtesting.MustIDBase16("7e55e118dbabb1ed"),
|
||||
RetentionPeriod: 24 * time.Hour,
|
||||
},
|
||||
}, 2, nil
|
||||
|
@ -115,7 +115,7 @@ func TestService_handleGetBuckets(t *testing.T) {
|
|||
"write": "/api/v2/write?org=50f7ba1150f7ba11&bucket=0b501e7e557ab1ed"
|
||||
},
|
||||
"id": "0b501e7e557ab1ed",
|
||||
"organizationID": "50f7ba1150f7ba11",
|
||||
"orgID": "50f7ba1150f7ba11",
|
||||
"name": "hello",
|
||||
"retentionRules": [{"type": "expire", "everySeconds": 2}],
|
||||
"labels": [
|
||||
|
@ -139,7 +139,7 @@ func TestService_handleGetBuckets(t *testing.T) {
|
|||
"write": "/api/v2/write?org=7e55e118dbabb1ed&bucket=c0175f0077a77005"
|
||||
},
|
||||
"id": "c0175f0077a77005",
|
||||
"organizationID": "7e55e118dbabb1ed",
|
||||
"orgID": "7e55e118dbabb1ed",
|
||||
"name": "example",
|
||||
"retentionRules": [{"type": "expire", "everySeconds": 86400}],
|
||||
"labels": [
|
||||
|
@ -251,7 +251,7 @@ func TestService_handleGetBucket(t *testing.T) {
|
|||
if id == platformtesting.MustIDBase16("020f755c3c082000") {
|
||||
return &platform.Bucket{
|
||||
ID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||
OrganizationID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||
OrgID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||
Name: "hello",
|
||||
RetentionPeriod: 30 * time.Second,
|
||||
}, nil
|
||||
|
@ -279,7 +279,7 @@ func TestService_handleGetBucket(t *testing.T) {
|
|||
"write": "/api/v2/write?org=020f755c3c082000&bucket=020f755c3c082000"
|
||||
},
|
||||
"id": "020f755c3c082000",
|
||||
"organizationID": "020f755c3c082000",
|
||||
"orgID": "020f755c3c082000",
|
||||
"name": "hello",
|
||||
"retentionRules": [{"type": "expire", "everySeconds": 30}],
|
||||
"labels": []
|
||||
|
@ -385,8 +385,8 @@ func TestService_handlePostBucket(t *testing.T) {
|
|||
},
|
||||
args: args{
|
||||
bucket: &platform.Bucket{
|
||||
Name: "hello",
|
||||
OrganizationID: platformtesting.MustIDBase16("6f626f7274697320"),
|
||||
Name: "hello",
|
||||
OrgID: platformtesting.MustIDBase16("6f626f7274697320"),
|
||||
},
|
||||
},
|
||||
wants: wants{
|
||||
|
@ -404,7 +404,7 @@ func TestService_handlePostBucket(t *testing.T) {
|
|||
"write": "/api/v2/write?org=6f626f7274697320&bucket=020f755c3c082000"
|
||||
},
|
||||
"id": "020f755c3c082000",
|
||||
"organizationID": "6f626f7274697320",
|
||||
"orgID": "6f626f7274697320",
|
||||
"name": "hello",
|
||||
"retentionRules": [],
|
||||
"labels": []
|
||||
|
@ -575,9 +575,9 @@ func TestService_handlePatchBucket(t *testing.T) {
|
|||
UpdateBucketFn: func(ctx context.Context, id platform.ID, upd platform.BucketUpdate) (*platform.Bucket, error) {
|
||||
if id == platformtesting.MustIDBase16("020f755c3c082000") {
|
||||
d := &platform.Bucket{
|
||||
ID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||
Name: "hello",
|
||||
OrganizationID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||
ID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||
Name: "hello",
|
||||
OrgID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||
}
|
||||
|
||||
if upd.Name != nil {
|
||||
|
@ -615,7 +615,7 @@ func TestService_handlePatchBucket(t *testing.T) {
|
|||
"write": "/api/v2/write?org=020f755c3c082000&bucket=020f755c3c082000"
|
||||
},
|
||||
"id": "020f755c3c082000",
|
||||
"organizationID": "020f755c3c082000",
|
||||
"orgID": "020f755c3c082000",
|
||||
"name": "example",
|
||||
"retentionRules": [{"type": "expire", "everySeconds": 2}],
|
||||
"labels": []
|
||||
|
@ -651,9 +651,9 @@ func TestService_handlePatchBucket(t *testing.T) {
|
|||
UpdateBucketFn: func(ctx context.Context, id platform.ID, upd platform.BucketUpdate) (*platform.Bucket, error) {
|
||||
if id == platformtesting.MustIDBase16("020f755c3c082000") {
|
||||
d := &platform.Bucket{
|
||||
ID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||
Name: "hello",
|
||||
OrganizationID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||
ID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||
Name: "hello",
|
||||
OrgID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||
}
|
||||
|
||||
if upd.Name != nil {
|
||||
|
@ -691,7 +691,7 @@ func TestService_handlePatchBucket(t *testing.T) {
|
|||
"write": "/api/v2/write?org=020f755c3c082000&bucket=020f755c3c082000"
|
||||
},
|
||||
"id": "020f755c3c082000",
|
||||
"organizationID": "020f755c3c082000",
|
||||
"orgID": "020f755c3c082000",
|
||||
"name": "bucket with no retention",
|
||||
"retentionRules": [],
|
||||
"labels": []
|
||||
|
@ -706,9 +706,9 @@ func TestService_handlePatchBucket(t *testing.T) {
|
|||
UpdateBucketFn: func(ctx context.Context, id platform.ID, upd platform.BucketUpdate) (*platform.Bucket, error) {
|
||||
if id == platformtesting.MustIDBase16("020f755c3c082000") {
|
||||
d := &platform.Bucket{
|
||||
ID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||
Name: "b1",
|
||||
OrganizationID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||
ID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||
Name: "b1",
|
||||
OrgID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||
}
|
||||
|
||||
if upd.Name != nil {
|
||||
|
@ -748,7 +748,7 @@ func TestService_handlePatchBucket(t *testing.T) {
|
|||
"write": "/api/v2/write?org=020f755c3c082000&bucket=020f755c3c082000"
|
||||
},
|
||||
"id": "020f755c3c082000",
|
||||
"organizationID": "020f755c3c082000",
|
||||
"orgID": "020f755c3c082000",
|
||||
"name": "b1",
|
||||
"retentionRules": [],
|
||||
"labels": []
|
||||
|
@ -763,9 +763,9 @@ func TestService_handlePatchBucket(t *testing.T) {
|
|||
UpdateBucketFn: func(ctx context.Context, id platform.ID, upd platform.BucketUpdate) (*platform.Bucket, error) {
|
||||
if id == platformtesting.MustIDBase16("020f755c3c082000") {
|
||||
d := &platform.Bucket{
|
||||
ID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||
Name: "hello",
|
||||
OrganizationID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||
ID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||
Name: "hello",
|
||||
OrgID: platformtesting.MustIDBase16("020f755c3c082000"),
|
||||
}
|
||||
|
||||
if upd.Name != nil {
|
||||
|
|
|
@ -1133,11 +1133,11 @@ func TestTaskHandler_CreateTaskWithOrgName(t *testing.T) {
|
|||
}
|
||||
|
||||
// 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 {
|
||||
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 {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -1240,11 +1240,11 @@ func TestTaskHandler_Sessions(t *testing.T) {
|
|||
}
|
||||
|
||||
// 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 {
|
||||
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 {
|
||||
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
|
||||
}
|
||||
|
||||
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.
|
||||
func (s *Service) FindBucketByID(ctx context.Context, id platform.ID) (*platform.Bucket, error) {
|
||||
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 {
|
||||
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 {
|
||||
// filter by bucket name
|
||||
|
@ -209,7 +193,7 @@ func (s *Service) findBuckets(ctx context.Context, filter platform.BucketFilter,
|
|||
} else if filter.OrganizationID != nil {
|
||||
// filter by organization id
|
||||
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
|
||||
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
|
||||
}
|
||||
|
||||
// CreateBucket creates a new bucket and sets b.ID with the new identifier.
|
||||
func (s *Service) CreateBucket(ctx context.Context, b *platform.Bucket) error {
|
||||
if b.OrganizationID.Valid() {
|
||||
_, pe := s.FindOrganizationByID(ctx, b.OrganizationID)
|
||||
if b.OrgID.Valid() {
|
||||
_, pe := s.FindOrganizationByID(ctx, b.OrgID)
|
||||
if pe != nil {
|
||||
return &platform.Error{
|
||||
Err: pe,
|
||||
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{
|
||||
Name: &b.Name,
|
||||
OrganizationID: &b.OrganizationID,
|
||||
OrganizationID: &b.OrgID,
|
||||
}
|
||||
if _, err := s.FindBucket(ctx, filter); err == nil {
|
||||
return &platform.Error{
|
||||
|
|
|
@ -77,8 +77,8 @@ func TestService_Name(t *testing.T) {
|
|||
Name: "o1",
|
||||
})
|
||||
return s.CreateBucket(ctx, &platform.Bucket{
|
||||
Name: "b1",
|
||||
OrganizationID: testID,
|
||||
Name: "b1",
|
||||
OrgID: testID,
|
||||
})
|
||||
},
|
||||
},
|
||||
|
|
|
@ -85,8 +85,7 @@ func (s *Service) Generate(ctx context.Context, req *platform.OnboardingRequest)
|
|||
}
|
||||
bucket := &platform.Bucket{
|
||||
Name: req.Bucket,
|
||||
Org: o.Name,
|
||||
OrganizationID: o.ID,
|
||||
OrgID: o.ID,
|
||||
RetentionPeriod: time.Duration(req.RetentionPeriod) * time.Hour,
|
||||
}
|
||||
if err = s.CreateBucket(ctx, bucket); err != nil {
|
||||
|
|
62
kv/bucket.go
62
kv/bucket.go
|
@ -47,20 +47,6 @@ func (s *Service) bucketsIndexBucket(tx Tx) (Bucket, error) {
|
|||
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.
|
||||
func (s *Service) FindBucketByID(ctx context.Context, id influxdb.ID) (*influxdb.Bucket, error) {
|
||||
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) {
|
||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
||||
span, _ := tracing.StartSpanFromContext(ctx)
|
||||
defer span.Finish()
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -159,8 +139,8 @@ func (s *Service) findBucketByName(ctx context.Context, tx Tx, orgID influxdb.ID
|
|||
defer span.Finish()
|
||||
|
||||
b := &influxdb.Bucket{
|
||||
OrganizationID: orgID,
|
||||
Name: n,
|
||||
OrgID: orgID,
|
||||
Name: n,
|
||||
}
|
||||
key, err := bucketIndexKey(b)
|
||||
if err != nil {
|
||||
|
@ -264,7 +244,7 @@ func filterBucketsFn(filter influxdb.BucketFilter) func(b *influxdb.Bucket) bool
|
|||
|
||||
if filter.Name != nil && filter.OrganizationID != nil {
|
||||
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 {
|
||||
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 {
|
||||
if b.OrganizationID.Valid() {
|
||||
if b.OrgID.Valid() {
|
||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
||||
defer span.Finish()
|
||||
|
||||
_, pe := s.findOrganizationByID(ctx, tx, b.OrganizationID)
|
||||
_, pe := s.findOrganizationByID(ctx, tx, b.OrgID)
|
||||
if pe != nil {
|
||||
return &influxdb.Error{
|
||||
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
|
||||
|
@ -446,7 +418,7 @@ func (s *Service) createBucketUserResourceMappings(ctx context.Context, tx Tx, b
|
|||
|
||||
ms, err := s.findUserResourceMappings(ctx, tx, influxdb.UserResourceMappingFilter{
|
||||
ResourceType: influxdb.OrgsResourceType,
|
||||
ResourceID: b.OrganizationID,
|
||||
ResourceID: b.OrgID,
|
||||
})
|
||||
if err != nil {
|
||||
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 {
|
||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
||||
span, _ := tracing.StartSpanFromContext(ctx)
|
||||
defer span.Finish()
|
||||
|
||||
b.Org = ""
|
||||
v, err := json.Marshal(b)
|
||||
if err != nil {
|
||||
return &influxdb.Error{
|
||||
|
@ -510,12 +481,12 @@ func (s *Service) putBucket(ctx context.Context, tx Tx, b *influxdb.Bucket) erro
|
|||
Err: err,
|
||||
}
|
||||
}
|
||||
return s.setOrganizationOnBucket(ctx, tx, b)
|
||||
return nil
|
||||
}
|
||||
|
||||
// bucketIndexKey is a combination of the orgID and the bucket name.
|
||||
func bucketIndexKey(b *influxdb.Bucket) ([]byte, error) {
|
||||
orgID, err := b.OrganizationID.Encode()
|
||||
orgID, err := b.OrgID.Encode()
|
||||
if err != nil {
|
||||
return nil, &influxdb.Error{
|
||||
Code: influxdb.EInvalid,
|
||||
|
@ -530,7 +501,7 @@ func bucketIndexKey(b *influxdb.Bucket) ([]byte, error) {
|
|||
|
||||
// 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 {
|
||||
span, ctx := tracing.StartSpanFromContext(ctx)
|
||||
span, _ := tracing.StartSpanFromContext(ctx)
|
||||
defer span.Finish()
|
||||
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
if err := s.setOrganizationOnBucket(ctx, tx, b); err != nil {
|
||||
return err
|
||||
}
|
||||
if !fn(b) {
|
||||
break
|
||||
}
|
||||
|
@ -622,7 +590,7 @@ func (s *Service) updateBucket(ctx context.Context, tx Tx, id influxdb.ID, upd i
|
|||
}
|
||||
|
||||
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 {
|
||||
return nil, &influxdb.Error{
|
||||
Code: influxdb.EConflict,
|
||||
|
@ -652,10 +620,6 @@ func (s *Service) updateBucket(ctx context.Context, tx Tx, id influxdb.ID, upd i
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if err := s.setOrganizationOnBucket(ctx, tx, b); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return b, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -88,8 +88,8 @@ func testLookupName(newStore StoreFn, t *testing.T) {
|
|||
Name: "o1",
|
||||
})
|
||||
return s.CreateBucket(ctx, &influxdb.Bucket{
|
||||
Name: "b1",
|
||||
OrganizationID: testID,
|
||||
Name: "b1",
|
||||
OrgID: testID,
|
||||
})
|
||||
},
|
||||
},
|
||||
|
|
|
@ -116,7 +116,6 @@ func (s *Service) Generate(ctx context.Context, req *influxdb.OnboardingRequest)
|
|||
o := &influxdb.Organization{Name: req.Org}
|
||||
bucket := &influxdb.Bucket{
|
||||
Name: req.Bucket,
|
||||
Org: o.Name,
|
||||
RetentionPeriod: time.Duration(req.RetentionPeriod) * time.Hour,
|
||||
}
|
||||
mapping := &influxdb.UserResourceMapping{
|
||||
|
@ -142,7 +141,7 @@ func (s *Service) Generate(ctx context.Context, req *influxdb.OnboardingRequest)
|
|||
return err
|
||||
}
|
||||
|
||||
bucket.OrganizationID = o.ID
|
||||
bucket.OrgID = o.ID
|
||||
if err := s.createBucket(ctx, tx, bucket); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -417,7 +417,7 @@ func (s *Service) deleteOrganizationsBuckets(ctx context.Context, tx Tx, id infl
|
|||
}
|
||||
for _, b := range bs {
|
||||
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
|
||||
|
@ -583,7 +583,7 @@ func (s *Service) FindResourceOrganizationID(ctx context.Context, rt influxdb.Re
|
|||
if err != nil {
|
||||
return influxdb.InvalidID(), err
|
||||
}
|
||||
return r.OrganizationID, nil
|
||||
return r.OrgID, nil
|
||||
case influxdb.OrgsResourceType:
|
||||
r, err := s.FindOrganizationByID(ctx, id)
|
||||
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")
|
||||
}
|
||||
|
||||
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 {
|
||||
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)
|
||||
}
|
||||
|
||||
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 {
|
||||
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")
|
||||
}
|
||||
|
||||
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 {
|
||||
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)
|
||||
}
|
||||
|
||||
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 {
|
||||
return nil, errors.Wrapf(err, "could not create write bucket permission")
|
||||
}
|
||||
|
|
|
@ -65,9 +65,9 @@ func TestPreAuthorizer_PreAuthorize(t *testing.T) {
|
|||
}
|
||||
orgID := platform.ID(1)
|
||||
bucketService := newBucketServiceWithOneBucket(platform.Bucket{
|
||||
Name: "my_bucket",
|
||||
ID: *bucketID,
|
||||
OrganizationID: orgID,
|
||||
Name: "my_bucket",
|
||||
ID: *bucketID,
|
||||
OrgID: orgID,
|
||||
})
|
||||
|
||||
preAuthorizer = query.NewPreAuthorizer(bucketService)
|
||||
|
@ -102,11 +102,11 @@ func TestPreAuthorizer_RequiredPermissions(t *testing.T) {
|
|||
if err := i.CreateOrganization(ctx, &o); err != nil {
|
||||
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 {
|
||||
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 {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ func (bd *BucketsDecoder) Fetch() (bool, error) {
|
|||
|
||||
func (bd *BucketsDecoder) Decode() (flux.Table, error) {
|
||||
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()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -60,12 +60,6 @@ func (bd *BucketsDecoder) Decode() (flux.Table, error) {
|
|||
}); err != nil {
|
||||
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{
|
||||
Label: "organizationID",
|
||||
Type: flux.TString,
|
||||
|
@ -88,10 +82,9 @@ func (bd *BucketsDecoder) Decode() (flux.Table, error) {
|
|||
for _, bucket := range bd.buckets {
|
||||
_ = b.AppendString(0, bucket.Name)
|
||||
_ = b.AppendString(1, bucket.ID.String())
|
||||
_ = b.AppendString(2, bucket.Org)
|
||||
_ = b.AppendString(3, bucket.OrganizationID.String())
|
||||
_ = b.AppendString(4, bucket.RetentionPolicyName)
|
||||
_ = b.AppendInt(5, bucket.RetentionPeriod.Nanoseconds())
|
||||
_ = b.AppendString(2, bucket.OrgID.String())
|
||||
_ = b.AppendString(3, bucket.RetentionPolicyName)
|
||||
_ = b.AppendInt(4, bucket.RetentionPeriod.Nanoseconds())
|
||||
}
|
||||
|
||||
return b.Table()
|
||||
|
|
|
@ -202,7 +202,7 @@ func testFlux(t testing.TB, l *launcher.TestLauncher, pkg *ast.Package) {
|
|||
// Query server to ensure write persists.
|
||||
|
||||
b := &platform.Bucket{
|
||||
Org: "ORG",
|
||||
OrgID: l.Org.ID,
|
||||
Name: t.Name(),
|
||||
RetentionPeriod: 0,
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ func testFlux(t testing.TB, l *launcher.TestLauncher, pkg *ast.Package) {
|
|||
orgOpt := &ast.OptionStatement{
|
||||
Assignment: &ast.VariableAssignment{
|
||||
ID: &ast.Identifier{Name: "org"},
|
||||
Init: &ast.StringLiteral{Value: b.Org},
|
||||
Init: &ast.StringLiteral{Value: l.Org.Name},
|
||||
},
|
||||
}
|
||||
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
|
||||
// reason, then the bucket will still be available in the future to retrieve
|
||||
// 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 s.inner.DeleteBucket(ctx, bucketID)
|
||||
|
|
|
@ -33,7 +33,7 @@ func TestBucketService(t *testing.T) {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
bucket := &platform.Bucket{OrganizationID: org.ID}
|
||||
bucket := &platform.Bucket{OrgID: org.ID}
|
||||
if err := inmemService.CreateBucket(context.TODO(), bucket); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
|
|
@ -113,14 +113,14 @@ func (s *retentionEnforcer) expireData(buckets []*influxdb.Bucket, now time.Time
|
|||
}
|
||||
|
||||
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 {
|
||||
logger.Info("unable to delete bucket range",
|
||||
zap.String("bucket id", b.ID.String()),
|
||||
zap.String("org id", b.OrganizationID.String()),
|
||||
zap.String("org id", b.OrgID.String()),
|
||||
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.
|
||||
if i%3 == 0 {
|
||||
buckets = append(buckets, &influxdb.Bucket{
|
||||
OrganizationID: orgID,
|
||||
OrgID: orgID,
|
||||
ID: bucketID,
|
||||
RetentionPeriod: 3 * time.Hour,
|
||||
})
|
||||
|
@ -48,7 +48,7 @@ func TestRetentionService(t *testing.T) {
|
|||
expRejected[string(name)] = struct{}{}
|
||||
} else if i%3 == 2 {
|
||||
buckets = append(buckets, &influxdb.Bucket{
|
||||
OrganizationID: orgID,
|
||||
OrgID: orgID,
|
||||
ID: bucketID,
|
||||
RetentionPeriod: 0,
|
||||
})
|
||||
|
|
|
@ -118,17 +118,16 @@ func CreateBucket(
|
|||
},
|
||||
args: args{
|
||||
bucket: &platform.Bucket{
|
||||
Name: "name1",
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "name1",
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
},
|
||||
},
|
||||
wants: wants{
|
||||
buckets: []*platform.Bucket{
|
||||
{
|
||||
Name: "name1",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Org: "theorg",
|
||||
Name: "name1",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -143,9 +142,9 @@ func CreateBucket(
|
|||
},
|
||||
Buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
Name: "bucket1",
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
Name: "bucket1",
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
},
|
||||
},
|
||||
Organizations: []*platform.Organization{
|
||||
|
@ -161,72 +160,21 @@ func CreateBucket(
|
|||
},
|
||||
args: args{
|
||||
bucket: &platform.Bucket{
|
||||
Name: "bucket2",
|
||||
OrganizationID: MustIDBase16(orgTwoID),
|
||||
Name: "bucket2",
|
||||
OrgID: MustIDBase16(orgTwoID),
|
||||
},
|
||||
},
|
||||
wants: wants{
|
||||
buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
Name: "bucket1",
|
||||
Org: "theorg",
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
Name: "bucket1",
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
Name: "bucket2",
|
||||
Org: "otherorg",
|
||||
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),
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
Name: "bucket2",
|
||||
OrgID: MustIDBase16(orgTwoID),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -241,9 +189,9 @@ func CreateBucket(
|
|||
},
|
||||
Buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
Name: "bucket1",
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
Name: "bucket1",
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
},
|
||||
},
|
||||
Organizations: []*platform.Organization{
|
||||
|
@ -259,17 +207,16 @@ func CreateBucket(
|
|||
},
|
||||
args: args{
|
||||
bucket: &platform.Bucket{
|
||||
Name: "bucket1",
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "bucket1",
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
},
|
||||
},
|
||||
wants: wants{
|
||||
buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
Name: "bucket1",
|
||||
Org: "theorg",
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
Name: "bucket1",
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
},
|
||||
},
|
||||
err: &platform.Error{
|
||||
|
@ -299,31 +246,29 @@ func CreateBucket(
|
|||
},
|
||||
Buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
Name: "bucket1",
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
Name: "bucket1",
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
},
|
||||
},
|
||||
},
|
||||
args: args{
|
||||
bucket: &platform.Bucket{
|
||||
Name: "bucket1",
|
||||
OrganizationID: MustIDBase16(orgTwoID),
|
||||
Name: "bucket1",
|
||||
OrgID: MustIDBase16(orgTwoID),
|
||||
},
|
||||
},
|
||||
wants: wants{
|
||||
buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
Name: "bucket1",
|
||||
Org: "theorg",
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
Name: "bucket1",
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
Name: "bucket1",
|
||||
Org: "otherorg",
|
||||
OrganizationID: MustIDBase16(orgTwoID),
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
Name: "bucket1",
|
||||
OrgID: MustIDBase16(orgTwoID),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -337,8 +282,8 @@ func CreateBucket(
|
|||
},
|
||||
args: args{
|
||||
bucket: &platform.Bucket{
|
||||
Name: "name1",
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "name1",
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
},
|
||||
},
|
||||
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 {
|
||||
|
@ -422,14 +345,14 @@ func FindBucketByID(
|
|||
fields: BucketFields{
|
||||
Buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "bucket1",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "bucket1",
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "bucket2",
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "bucket2",
|
||||
},
|
||||
},
|
||||
Organizations: []*platform.Organization{
|
||||
|
@ -444,10 +367,9 @@ func FindBucketByID(
|
|||
},
|
||||
wants: wants{
|
||||
bucket: &platform.Bucket{
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Org: "theorg",
|
||||
Name: "bucket2",
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "bucket2",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -456,14 +378,14 @@ func FindBucketByID(
|
|||
fields: BucketFields{
|
||||
Buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "bucket1",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "bucket1",
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "bucket2",
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "bucket2",
|
||||
},
|
||||
},
|
||||
Organizations: []*platform.Organization{
|
||||
|
@ -540,14 +462,14 @@ func FindBuckets(
|
|||
},
|
||||
Buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "abc",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "abc",
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrganizationID: MustIDBase16(orgTwoID),
|
||||
Name: "xyz",
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrgID: MustIDBase16(orgTwoID),
|
||||
Name: "xyz",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -555,16 +477,14 @@ func FindBuckets(
|
|||
wants: wants{
|
||||
buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Org: "theorg",
|
||||
Name: "abc",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "abc",
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrganizationID: MustIDBase16(orgTwoID),
|
||||
Org: "otherorg",
|
||||
Name: "xyz",
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrgID: MustIDBase16(orgTwoID),
|
||||
Name: "xyz",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -580,19 +500,19 @@ func FindBuckets(
|
|||
},
|
||||
Buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "abc",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "abc",
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "def",
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "def",
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(bucketThreeID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "xyz",
|
||||
ID: MustIDBase16(bucketThreeID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "xyz",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -605,10 +525,9 @@ func FindBuckets(
|
|||
wants: wants{
|
||||
buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Org: "theorg",
|
||||
Name: "def",
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "def",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -624,19 +543,19 @@ func FindBuckets(
|
|||
},
|
||||
Buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "abc",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "abc",
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "def",
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "def",
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(bucketThreeID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "xyz",
|
||||
ID: MustIDBase16(bucketThreeID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "xyz",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -649,16 +568,14 @@ func FindBuckets(
|
|||
wants: wants{
|
||||
buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Org: "theorg",
|
||||
Name: "def",
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "def",
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Org: "theorg",
|
||||
Name: "abc",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "abc",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -678,19 +595,19 @@ func FindBuckets(
|
|||
},
|
||||
Buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "abc",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "abc",
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrganizationID: MustIDBase16(orgTwoID),
|
||||
Name: "xyz",
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrgID: MustIDBase16(orgTwoID),
|
||||
Name: "xyz",
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(bucketThreeID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "123",
|
||||
ID: MustIDBase16(bucketThreeID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "123",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -700,16 +617,14 @@ func FindBuckets(
|
|||
wants: wants{
|
||||
buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Org: "theorg",
|
||||
Name: "abc",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "abc",
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(bucketThreeID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Org: "theorg",
|
||||
Name: "123",
|
||||
ID: MustIDBase16(bucketThreeID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "123",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -729,19 +644,19 @@ func FindBuckets(
|
|||
},
|
||||
Buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "abc",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "abc",
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrganizationID: MustIDBase16(orgTwoID),
|
||||
Name: "xyz",
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrgID: MustIDBase16(orgTwoID),
|
||||
Name: "xyz",
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(bucketThreeID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "123",
|
||||
ID: MustIDBase16(bucketThreeID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "123",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -751,16 +666,14 @@ func FindBuckets(
|
|||
wants: wants{
|
||||
buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Org: "theorg",
|
||||
Name: "abc",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "abc",
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(bucketThreeID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Org: "theorg",
|
||||
Name: "123",
|
||||
ID: MustIDBase16(bucketThreeID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "123",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -776,14 +689,14 @@ func FindBuckets(
|
|||
},
|
||||
Buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "abc",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "abc",
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "xyz",
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "xyz",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -793,10 +706,9 @@ func FindBuckets(
|
|||
wants: wants{
|
||||
buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Org: "theorg",
|
||||
Name: "xyz",
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "xyz",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -879,14 +791,14 @@ func DeleteBucket(
|
|||
},
|
||||
Buckets: []*platform.Bucket{
|
||||
{
|
||||
Name: "A",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "A",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
},
|
||||
{
|
||||
Name: "B",
|
||||
ID: MustIDBase16(bucketThreeID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "B",
|
||||
ID: MustIDBase16(bucketThreeID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -896,10 +808,9 @@ func DeleteBucket(
|
|||
wants: wants{
|
||||
buckets: []*platform.Bucket{
|
||||
{
|
||||
Name: "B",
|
||||
ID: MustIDBase16(bucketThreeID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Org: "theorg",
|
||||
Name: "B",
|
||||
ID: MustIDBase16(bucketThreeID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -915,14 +826,14 @@ func DeleteBucket(
|
|||
},
|
||||
Buckets: []*platform.Bucket{
|
||||
{
|
||||
Name: "A",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "A",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
},
|
||||
{
|
||||
Name: "B",
|
||||
ID: MustIDBase16(bucketThreeID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "B",
|
||||
ID: MustIDBase16(bucketThreeID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -937,16 +848,14 @@ func DeleteBucket(
|
|||
},
|
||||
buckets: []*platform.Bucket{
|
||||
{
|
||||
Name: "A",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Org: "theorg",
|
||||
Name: "A",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
},
|
||||
{
|
||||
Name: "B",
|
||||
ID: MustIDBase16(bucketThreeID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Org: "theorg",
|
||||
Name: "B",
|
||||
ID: MustIDBase16(bucketThreeID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1005,14 +914,14 @@ func FindBucket(
|
|||
},
|
||||
Buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "abc",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "abc",
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "xyz",
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "xyz",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1022,10 +931,9 @@ func FindBucket(
|
|||
},
|
||||
wants: wants{
|
||||
bucket: &platform.Bucket{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Org: "theorg",
|
||||
Name: "abc",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "abc",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1109,14 +1017,14 @@ func UpdateBucket(
|
|||
},
|
||||
Buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "bucket1",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "bucket1",
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "bucket2",
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "bucket2",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1126,10 +1034,9 @@ func UpdateBucket(
|
|||
},
|
||||
wants: wants{
|
||||
bucket: &platform.Bucket{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Org: "theorg",
|
||||
Name: "changed",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "changed",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1144,14 +1051,14 @@ func UpdateBucket(
|
|||
},
|
||||
Buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "bucket1",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "bucket1",
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "bucket2",
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "bucket2",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1177,14 +1084,14 @@ func UpdateBucket(
|
|||
},
|
||||
Buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "bucket1",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "bucket1",
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "bucket2",
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "bucket2",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1195,8 +1102,7 @@ func UpdateBucket(
|
|||
wants: wants{
|
||||
bucket: &platform.Bucket{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Org: "theorg",
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "bucket1",
|
||||
RetentionPeriod: 100 * time.Minute,
|
||||
},
|
||||
|
@ -1213,14 +1119,14 @@ func UpdateBucket(
|
|||
},
|
||||
Buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "bucket1",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "bucket1",
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "bucket2",
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "bucket2",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1232,8 +1138,7 @@ func UpdateBucket(
|
|||
wants: wants{
|
||||
bucket: &platform.Bucket{
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Org: "theorg",
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "changed",
|
||||
RetentionPeriod: 101 * time.Minute,
|
||||
},
|
||||
|
@ -1250,14 +1155,14 @@ func UpdateBucket(
|
|||
},
|
||||
Buckets: []*platform.Bucket{
|
||||
{
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "bucket1",
|
||||
ID: MustIDBase16(bucketOneID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "bucket1",
|
||||
},
|
||||
{
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Name: "bucket2",
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "bucket2",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1269,8 +1174,7 @@ func UpdateBucket(
|
|||
wants: wants{
|
||||
bucket: &platform.Bucket{
|
||||
ID: MustIDBase16(bucketTwoID),
|
||||
OrganizationID: MustIDBase16(orgOneID),
|
||||
Org: "theorg",
|
||||
OrgID: MustIDBase16(orgOneID),
|
||||
Name: "bucket2",
|
||||
RetentionPeriod: 101 * time.Minute,
|
||||
},
|
||||
|
|
|
@ -159,8 +159,7 @@ func Generate(
|
|||
Bucket: &platform.Bucket{
|
||||
ID: MustIDBase16(threeID),
|
||||
Name: "bucket1",
|
||||
Org: "org1",
|
||||
OrganizationID: MustIDBase16(twoID),
|
||||
OrgID: MustIDBase16(twoID),
|
||||
RetentionPeriod: time.Hour * 24 * 7,
|
||||
},
|
||||
Auth: &platform.Authorization{
|
||||
|
|
Loading…
Reference in New Issue