Merge pull request #13557 from influxdata/bucket_desc
feat(influxdb): add bucket descpull/13590/head
commit
3bc1c49e91
|
@ -521,6 +521,10 @@ func (c *Client) updateBucket(ctx context.Context, tx *bolt.Tx, id platform.ID,
|
||||||
b.RetentionPeriod = *upd.RetentionPeriod
|
b.RetentionPeriod = *upd.RetentionPeriod
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if upd.Description != nil {
|
||||||
|
b.Description = *upd.Description
|
||||||
|
}
|
||||||
|
|
||||||
if upd.Name != nil {
|
if upd.Name != nil {
|
||||||
b0, err := c.findBucketByName(ctx, tx, b.OrgID, *upd.Name)
|
b0, err := c.findBucketByName(ctx, tx, b.OrgID, *upd.Name)
|
||||||
if err == nil && b0.ID != id {
|
if err == nil && b0.ID != id {
|
||||||
|
|
|
@ -23,6 +23,7 @@ type Bucket struct {
|
||||||
ID ID `json:"id,omitempty"`
|
ID ID `json:"id,omitempty"`
|
||||||
OrgID ID `json:"orgID,omitempty"`
|
OrgID ID `json:"orgID,omitempty"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
|
Description string `json:"description"`
|
||||||
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"`
|
||||||
}
|
}
|
||||||
|
@ -64,6 +65,7 @@ type BucketService interface {
|
||||||
// Only fields which are set are updated.
|
// Only fields which are set are updated.
|
||||||
type BucketUpdate struct {
|
type BucketUpdate struct {
|
||||||
Name *string `json:"name,omitempty"`
|
Name *string `json:"name,omitempty"`
|
||||||
|
Description *string `json:"description,omitempty"`
|
||||||
RetentionPeriod *time.Duration `json:"retentionPeriod,omitempty"`
|
RetentionPeriod *time.Duration `json:"retentionPeriod,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,6 +128,7 @@ func NewBucketHandler(b *BucketBackend) *BucketHandler {
|
||||||
type bucket struct {
|
type bucket struct {
|
||||||
ID influxdb.ID `json:"id,omitempty"`
|
ID influxdb.ID `json:"id,omitempty"`
|
||||||
OrgID influxdb.ID `json:"orgID,omitempty"`
|
OrgID influxdb.ID `json:"orgID,omitempty"`
|
||||||
|
Description string `json:"description,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,6 +161,7 @@ func (b *bucket) toInfluxDB() (*influxdb.Bucket, error) {
|
||||||
return &influxdb.Bucket{
|
return &influxdb.Bucket{
|
||||||
ID: b.ID,
|
ID: b.ID,
|
||||||
OrgID: b.OrgID,
|
OrgID: b.OrgID,
|
||||||
|
Description: b.Description,
|
||||||
Name: b.Name,
|
Name: b.Name,
|
||||||
RetentionPolicyName: b.RetentionPolicyName,
|
RetentionPolicyName: b.RetentionPolicyName,
|
||||||
RetentionPeriod: d,
|
RetentionPeriod: d,
|
||||||
|
@ -184,6 +186,7 @@ func newBucket(pb *influxdb.Bucket) *bucket {
|
||||||
ID: pb.ID,
|
ID: pb.ID,
|
||||||
OrgID: pb.OrgID,
|
OrgID: pb.OrgID,
|
||||||
Name: pb.Name,
|
Name: pb.Name,
|
||||||
|
Description: pb.Description,
|
||||||
RetentionPolicyName: pb.RetentionPolicyName,
|
RetentionPolicyName: pb.RetentionPolicyName,
|
||||||
RetentionRules: rules,
|
RetentionRules: rules,
|
||||||
}
|
}
|
||||||
|
@ -192,6 +195,7 @@ func newBucket(pb *influxdb.Bucket) *bucket {
|
||||||
// bucketUpdate is used for serialization/deserialization with retention rules.
|
// bucketUpdate is used for serialization/deserialization with retention rules.
|
||||||
type bucketUpdate struct {
|
type bucketUpdate struct {
|
||||||
Name *string `json:"name,omitempty"`
|
Name *string `json:"name,omitempty"`
|
||||||
|
Description *string `json:"description,omitempty"`
|
||||||
RetentionRules []retentionRule `json:"retentionRules,omitempty"`
|
RetentionRules []retentionRule `json:"retentionRules,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -214,6 +218,7 @@ func (b *bucketUpdate) toInfluxDB() (*influxdb.BucketUpdate, error) {
|
||||||
|
|
||||||
return &influxdb.BucketUpdate{
|
return &influxdb.BucketUpdate{
|
||||||
Name: b.Name,
|
Name: b.Name,
|
||||||
|
Description: b.Description,
|
||||||
RetentionPeriod: &d,
|
RetentionPeriod: &d,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -225,6 +230,7 @@ func newBucketUpdate(pb *influxdb.BucketUpdate) *bucketUpdate {
|
||||||
|
|
||||||
up := &bucketUpdate{
|
up := &bucketUpdate{
|
||||||
Name: pb.Name,
|
Name: pb.Name,
|
||||||
|
Description: pb.Description,
|
||||||
RetentionRules: []retentionRule{},
|
RetentionRules: []retentionRule{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5562,6 +5562,8 @@ components:
|
||||||
type: string
|
type: string
|
||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
|
description:
|
||||||
|
type: string
|
||||||
organizationID:
|
organizationID:
|
||||||
type: string
|
type: string
|
||||||
organization:
|
organization:
|
||||||
|
|
|
@ -270,6 +270,10 @@ func (s *Service) UpdateBucket(ctx context.Context, id platform.ID, upd platform
|
||||||
b.RetentionPeriod = *upd.RetentionPeriod
|
b.RetentionPeriod = *upd.RetentionPeriod
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if upd.Description != nil {
|
||||||
|
b.Description = *upd.Description
|
||||||
|
}
|
||||||
|
|
||||||
b0, err := s.FindBucket(ctx, platform.BucketFilter{
|
b0, err := s.FindBucket(ctx, platform.BucketFilter{
|
||||||
Name: upd.Name,
|
Name: upd.Name,
|
||||||
})
|
})
|
||||||
|
|
|
@ -589,6 +589,10 @@ func (s *Service) updateBucket(ctx context.Context, tx Tx, id influxdb.ID, upd i
|
||||||
b.RetentionPeriod = *upd.RetentionPeriod
|
b.RetentionPeriod = *upd.RetentionPeriod
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if upd.Description != nil {
|
||||||
|
b.Description = *upd.Description
|
||||||
|
}
|
||||||
|
|
||||||
if upd.Name != nil {
|
if upd.Name != nil {
|
||||||
b0, err := s.findBucketByName(ctx, tx, b.OrgID, *upd.Name)
|
b0, err := s.findBucketByName(ctx, tx, b.OrgID, *upd.Name)
|
||||||
if err == nil && b0.ID != id {
|
if err == nil && b0.ID != id {
|
||||||
|
|
|
@ -118,16 +118,18 @@ func CreateBucket(
|
||||||
},
|
},
|
||||||
args: args{
|
args: args{
|
||||||
bucket: &platform.Bucket{
|
bucket: &platform.Bucket{
|
||||||
Name: "name1",
|
Name: "name1",
|
||||||
OrgID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
|
Description: "desc1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
wants: wants{
|
wants: wants{
|
||||||
buckets: []*platform.Bucket{
|
buckets: []*platform.Bucket{
|
||||||
{
|
{
|
||||||
Name: "name1",
|
Name: "name1",
|
||||||
ID: MustIDBase16(bucketOneID),
|
ID: MustIDBase16(bucketOneID),
|
||||||
OrgID: MustIDBase16(orgOneID),
|
OrgID: MustIDBase16(orgOneID),
|
||||||
|
Description: "desc1",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -991,9 +993,10 @@ func UpdateBucket(
|
||||||
t *testing.T,
|
t *testing.T,
|
||||||
) {
|
) {
|
||||||
type args struct {
|
type args struct {
|
||||||
name string
|
name string
|
||||||
id platform.ID
|
id platform.ID
|
||||||
retention int
|
retention int
|
||||||
|
description *string
|
||||||
}
|
}
|
||||||
type wants struct {
|
type wants struct {
|
||||||
err error
|
err error
|
||||||
|
@ -1108,6 +1111,41 @@ func UpdateBucket(
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "update description",
|
||||||
|
fields: BucketFields{
|
||||||
|
Organizations: []*platform.Organization{
|
||||||
|
{
|
||||||
|
Name: "theorg",
|
||||||
|
ID: MustIDBase16(orgOneID),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Buckets: []*platform.Bucket{
|
||||||
|
{
|
||||||
|
ID: MustIDBase16(bucketOneID),
|
||||||
|
OrgID: MustIDBase16(orgOneID),
|
||||||
|
Name: "bucket1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ID: MustIDBase16(bucketTwoID),
|
||||||
|
OrgID: MustIDBase16(orgOneID),
|
||||||
|
Name: "bucket2",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
args: args{
|
||||||
|
id: MustIDBase16(bucketOneID),
|
||||||
|
description: stringPtr("desc1"),
|
||||||
|
},
|
||||||
|
wants: wants{
|
||||||
|
bucket: &platform.Bucket{
|
||||||
|
ID: MustIDBase16(bucketOneID),
|
||||||
|
OrgID: MustIDBase16(orgOneID),
|
||||||
|
Name: "bucket1",
|
||||||
|
Description: "desc1",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "update retention and name",
|
name: "update retention and name",
|
||||||
fields: BucketFields{
|
fields: BucketFields{
|
||||||
|
@ -1197,6 +1235,8 @@ func UpdateBucket(
|
||||||
upd.RetentionPeriod = &d
|
upd.RetentionPeriod = &d
|
||||||
}
|
}
|
||||||
|
|
||||||
|
upd.Description = tt.args.description
|
||||||
|
|
||||||
bucket, err := s.UpdateBucket(ctx, tt.args.id, upd)
|
bucket, err := s.UpdateBucket(ctx, tt.args.id, upd)
|
||||||
diffPlatformErrors(tt.name, err, tt.wants.err, opPrefix, t)
|
diffPlatformErrors(tt.name, err, tt.wants.err, opPrefix, t)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue