Skip to content

Commit

Permalink
rename bucket organization to org
Browse files Browse the repository at this point in the history
  • Loading branch information
kelwang committed Apr 22, 2019
1 parent 432c462 commit 9d44ac3
Show file tree
Hide file tree
Showing 17 changed files with 84 additions and 84 deletions.
14 changes: 7 additions & 7 deletions bolt/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func (c *Client) setOrganizationOnBucket(ctx context.Context, tx *bolt.Tx, b *pl
Err: err,
}
}
b.Organization = o.Name
b.Org = o.Name
return nil
}

Expand Down Expand Up @@ -189,8 +189,8 @@ func (c *Client) FindBucket(ctx context.Context, filter platform.BucketFilter) (
}

err = c.db.View(func(tx *bolt.Tx) error {
if filter.Organization != nil {
o, err := c.findOrganizationByName(ctx, tx, *filter.Organization)
if filter.Org != nil {
o, err := c.findOrganizationByName(ctx, tx, *filter.Org)
if err != nil {
return err
}
Expand Down Expand Up @@ -299,8 +299,8 @@ func (c *Client) findBuckets(ctx context.Context, tx *bolt.Tx, filter platform.B
defer span.Finish()

bs := []*platform.Bucket{}
if filter.Organization != nil {
o, err := c.findOrganizationByName(ctx, tx, *filter.Organization)
if filter.Org != nil {
o, err := c.findOrganizationByName(ctx, tx, *filter.Org)
if err != nil {
return nil, &platform.Error{
Err: err,
Expand Down Expand Up @@ -359,7 +359,7 @@ func (c *Client) CreateBucket(ctx context.Context, b *platform.Bucket) error {
}
}
} else {
o, pe := c.findOrganizationByName(ctx, tx, b.Organization)
o, pe := c.findOrganizationByName(ctx, tx, b.Org)
if pe != nil {
return &platform.Error{
Err: pe,
Expand Down Expand Up @@ -442,7 +442,7 @@ 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.Organization = ""
b.Org = ""
v, err := json.Marshal(b)
if err != nil {
return &platform.Error{
Expand Down
2 changes: 1 addition & 1 deletion bolt/onboarding.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (c *Client) Generate(ctx context.Context, req *platform.OnboardingRequest)
}
bucket := &platform.Bucket{
Name: req.Bucket,
Organization: o.Name,
Org: o.Name,
OrganizationID: o.ID,
RetentionPeriod: time.Duration(req.RetentionPeriod) * time.Hour,
}
Expand Down
12 changes: 6 additions & 6 deletions bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const InfiniteRetention = 0
type Bucket struct {
ID ID `json:"id,omitempty"`
OrganizationID ID `json:"orgID,omitempty"`
Organization string `json:"organization,omitempty"`
Org string `json:"org,omitempty"`
Name string `json:"name"`
RetentionPolicyName string `json:"rp,omitempty"` // This to support v1 sources
RetentionPeriod time.Duration `json:"retentionPeriod"`
Expand Down Expand Up @@ -73,7 +73,7 @@ type BucketFilter struct {
ID *ID
Name *string
OrganizationID *ID
Organization *string
Org *string
}

// QueryParams Converts BucketFilter fields to url query params.
Expand All @@ -91,8 +91,8 @@ func (f BucketFilter) QueryParams() map[string][]string {
qp["orgID"] = []string{f.OrganizationID.String()}
}

if f.Organization != nil {
qp["org"] = []string{*f.Organization}
if f.Org != nil {
qp["org"] = []string{*f.Org}
}

return qp
Expand All @@ -112,8 +112,8 @@ func (f BucketFilter) String() string {
if f.OrganizationID != nil {
parts = append(parts, "Org ID: "+f.OrganizationID.String())
}
if f.Organization != nil {
parts = append(parts, "Org Name: "+*f.Organization)
if f.Org != nil {
parts = append(parts, "Org Name: "+*f.Org)
}
return "[" + strings.Join(parts, ", ") + "]"
}
Expand Down
16 changes: 8 additions & 8 deletions cmd/influx/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func bucketCreateF(cmd *cobra.Command, args []string) error {
}

if bucketCreateFlags.org != "" {
b.Organization = bucketCreateFlags.org
b.Org = bucketCreateFlags.org
}

if bucketCreateFlags.orgID != "" {
Expand All @@ -96,14 +96,14 @@ func bucketCreateF(cmd *cobra.Command, args []string) error {
"ID",
"Name",
"Retention",
"Organization",
"Org",
"OrganizationID",
)
w.Write(map[string]interface{}{
"ID": b.ID.String(),
"Name": b.Name,
"Retention": b.RetentionPeriod,
"Organization": b.Organization,
"Org": b.Org,
"OrganizationID": b.OrganizationID.String(),
})
w.Flush()
Expand Down Expand Up @@ -168,7 +168,7 @@ func bucketFindF(cmd *cobra.Command, args []string) error {
}

if bucketFindFlags.org != "" {
filter.Organization = &bucketFindFlags.org
filter.Org = &bucketFindFlags.org
}

buckets, _, err := s.FindBuckets(context.Background(), filter)
Expand All @@ -181,15 +181,15 @@ func bucketFindF(cmd *cobra.Command, args []string) error {
"ID",
"Name",
"Retention",
"Organization",
"Org",
"OrganizationID",
)
for _, b := range buckets {
w.Write(map[string]interface{}{
"ID": b.ID.String(),
"Name": b.Name,
"Retention": b.RetentionPeriod,
"Organization": b.Organization,
"Org": b.Org,
"OrganizationID": b.OrganizationID.String(),
})
}
Expand Down Expand Up @@ -258,7 +258,7 @@ func bucketUpdateF(cmd *cobra.Command, args []string) error {
"ID": b.ID.String(),
"Name": b.Name,
"Retention": b.RetentionPeriod,
"Organization": b.Organization,
"Org": b.Org,
"OrganizationID": b.OrganizationID.String(),
})
w.Flush()
Expand Down Expand Up @@ -307,7 +307,7 @@ func bucketDeleteF(cmd *cobra.Command, args []string) error {
"ID": b.ID.String(),
"Name": b.Name,
"Retention": b.RetentionPeriod,
"Organization": b.Organization,
"Org": b.Org,
"OrganizationID": b.OrganizationID.String(),
"Deleted": true,
})
Expand Down
2 changes: 1 addition & 1 deletion cmd/influx/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func fluxWriteF(cmd *cobra.Command, args []string) error {
}
}
if writeFlags.Org != "" {
filter.Organization = &writeFlags.Org
filter.Org = &writeFlags.Org
}

buckets, n, err := bs.FindBuckets(ctx, filter)
Expand Down
4 changes: 2 additions & 2 deletions cmd/influxd/launcher/tasks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, Organization: org.Name, Name: "my_bucket_in"}
bIn := &influxdb.Bucket{OrganizationID: org.ID, Org: org.Name, Name: "my_bucket_in"}
if err := be.BucketService().CreateBucket(context.Background(), bIn); err != nil {
t.Fatal(err)
}
bOut := &influxdb.Bucket{OrganizationID: org.ID, Organization: org.Name, Name: "my_bucket_out"}
bOut := &influxdb.Bucket{OrganizationID: org.ID, Org: org.Name, Name: "my_bucket_out"}
if err := be.BucketService().CreateBucket(context.Background(), bOut); err != nil {
t.Fatal(err)
}
Expand Down
16 changes: 8 additions & 8 deletions http/bucket_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func NewBucketHandler(b *BucketBackend) *BucketHandler {
type bucket struct {
ID influxdb.ID `json:"id,omitempty"`
OrganizationID influxdb.ID `json:"organizationID,omitempty"`
Organization string `json:"organization,omitempty"`
Org string `json:"org,omitempty"`
Name string `json:"name"`
RetentionPolicyName string `json:"rp,omitempty"` // This to support v1 sources
RetentionRules []retentionRule `json:"retentionRules"`
Expand Down Expand Up @@ -161,7 +161,7 @@ func (b *bucket) toInfluxDB() (*influxdb.Bucket, error) {
return &influxdb.Bucket{
ID: b.ID,
OrganizationID: b.OrganizationID,
Organization: b.Organization,
Org: b.Org,
Name: b.Name,
RetentionPolicyName: b.RetentionPolicyName,
RetentionPeriod: d,
Expand All @@ -185,7 +185,7 @@ func newBucket(pb *influxdb.Bucket) *bucket {
return &bucket{
ID: pb.ID,
OrganizationID: pb.OrganizationID,
Organization: pb.Organization,
Org: pb.Org,
Name: pb.Name,
RetentionPolicyName: pb.RetentionPolicyName,
RetentionRules: rules,
Expand Down Expand Up @@ -298,7 +298,7 @@ func (h *BucketHandler) handlePostBucket(w http.ResponseWriter, r *http.Request)

if !req.Bucket.OrganizationID.Valid() {
// Resolve organization name to ID before create
o, err := h.OrganizationService.FindOrganization(ctx, influxdb.OrganizationFilter{Name: &req.Bucket.Organization})
o, err := h.OrganizationService.FindOrganization(ctx, influxdb.OrganizationFilter{Name: &req.Bucket.Org})
if err != nil {
EncodeError(ctx, err, w)
return
Expand All @@ -322,7 +322,7 @@ type postBucketRequest struct {
}

func (b postBucketRequest) Validate() error {
if b.Bucket.Organization == "" && !b.Bucket.OrganizationID.Valid() {
if b.Bucket.Org == "" && !b.Bucket.OrganizationID.Valid() {
return fmt.Errorf("bucket requires an organization")
}
return nil
Expand Down Expand Up @@ -492,7 +492,7 @@ func decodeGetBucketsRequest(ctx context.Context, r *http.Request) (*getBucketsR
}

if org := qp.Get("org"); org != "" {
req.filter.Organization = &org
req.filter.Org = &org
}

if name := qp.Get("name"); name != "" {
Expand Down Expand Up @@ -671,8 +671,8 @@ func (s *BucketService) FindBuckets(ctx context.Context, filter influxdb.BucketF
if filter.OrganizationID != nil {
query.Add("orgID", filter.OrganizationID.String())
}
if filter.Organization != nil {
query.Add("org", *filter.Organization)
if filter.Org != nil {
query.Add("org", *filter.Org)
}
if filter.ID != nil {
query.Add("id", filter.ID.String())
Expand Down
8 changes: 4 additions & 4 deletions inmem/bucket_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (s *Service) setOrganizationNameOnBucket(ctx context.Context, b *platform.B
return err
}

b.Organization = o.Name
b.Org = o.Name
return nil
}

Expand Down Expand Up @@ -185,8 +185,8 @@ func (s *Service) findBuckets(ctx context.Context, filter platform.BucketFilter,
return []*platform.Bucket{b}, nil
}

if filter.Organization != nil {
o, err := s.findOrganizationByName(ctx, *filter.Organization)
if filter.Org != nil {
o, err := s.findOrganizationByName(ctx, *filter.Org)
if err != nil {
return nil, &platform.Error{
Err: err,
Expand Down Expand Up @@ -251,7 +251,7 @@ func (s *Service) CreateBucket(ctx context.Context, b *platform.Bucket) error {
}
}
} else {
o, pe := s.findOrganizationByName(ctx, b.Organization)
o, pe := s.findOrganizationByName(ctx, b.Org)
if pe != nil {
return &platform.Error{
Err: pe,
Expand Down
2 changes: 1 addition & 1 deletion inmem/onboarding.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (s *Service) Generate(ctx context.Context, req *platform.OnboardingRequest)
}
bucket := &platform.Bucket{
Name: req.Bucket,
Organization: o.Name,
Org: o.Name,
OrganizationID: o.ID,
RetentionPeriod: time.Duration(req.RetentionPeriod) * time.Hour,
}
Expand Down
14 changes: 7 additions & 7 deletions kv/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (s *Service) setOrganizationOnBucket(ctx context.Context, tx Tx, b *influxd
Err: err,
}
}
b.Organization = o.Name
b.Org = o.Name
return nil
}

Expand Down Expand Up @@ -221,8 +221,8 @@ func (s *Service) FindBucket(ctx context.Context, filter influxdb.BucketFilter)
}

err = s.kv.View(ctx, func(tx Tx) error {
if filter.Organization != nil {
o, err := s.findOrganizationByName(ctx, tx, *filter.Organization)
if filter.Org != nil {
o, err := s.findOrganizationByName(ctx, tx, *filter.Org)
if err != nil {
return err
}
Expand Down Expand Up @@ -330,8 +330,8 @@ func (s *Service) findBuckets(ctx context.Context, tx Tx, filter influxdb.Bucket
defer span.Finish()

bs := []*influxdb.Bucket{}
if filter.Organization != nil {
o, err := s.findOrganizationByName(ctx, tx, *filter.Organization)
if filter.Org != nil {
o, err := s.findOrganizationByName(ctx, tx, *filter.Org)
if err != nil {
return nil, &influxdb.Error{
Err: err,
Expand Down Expand Up @@ -395,7 +395,7 @@ func (s *Service) createBucket(ctx context.Context, tx Tx, b *influxdb.Bucket) e
}
}
} else {
o, pe := s.findOrganizationByName(ctx, tx, b.Organization)
o, pe := s.findOrganizationByName(ctx, tx, b.Org)
if pe != nil {
return &influxdb.Error{
Err: pe,
Expand Down Expand Up @@ -474,7 +474,7 @@ func (s *Service) putBucket(ctx context.Context, tx Tx, b *influxdb.Bucket) erro
span, ctx := tracing.StartSpanFromContext(ctx)
defer span.Finish()

b.Organization = ""
b.Org = ""
v, err := json.Marshal(b)
if err != nil {
return &influxdb.Error{
Expand Down
2 changes: 1 addition & 1 deletion kv/onboarding.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (s *Service) Generate(ctx context.Context, req *influxdb.OnboardingRequest)
o := &influxdb.Organization{Name: req.Org}
bucket := &influxdb.Bucket{
Name: req.Bucket,
Organization: o.Name,
Org: o.Name,
RetentionPeriod: time.Duration(req.RetentionPeriod) * time.Hour,
}
mapping := &influxdb.UserResourceMapping{
Expand Down
2 changes: 1 addition & 1 deletion query/stdlib/influxdata/influxdb/buckets.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ 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.Organization)
_ = b.AppendString(2, bucket.Org)
_ = b.AppendString(3, bucket.OrganizationID.String())
_ = b.AppendString(4, bucket.RetentionPolicyName)
_ = b.AppendInt(5, bucket.RetentionPeriod.Nanoseconds())
Expand Down
2 changes: 1 addition & 1 deletion query/stdlib/influxdata/influxdb/to.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func (o *ToOpSpec) BucketsAccessed(orgID *platform.ID) (readBuckets, writeBucket
bf.Name = &o.Bucket
}
if o.Org != "" {
bf.Organization = &o.Org
bf.Org = &o.Org
}
if o.OrgID != "" {
id, err := platform.IDFromString(o.OrgID)
Expand Down
2 changes: 1 addition & 1 deletion query/stdlib/influxdata/influxdb/to_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestToOpSpec_BucketsAccessed(t *testing.T) {
Name: "from() with bucket and to with org and bucket",
Raw: fmt.Sprintf(`from(bucket:"%s") |> to(bucket:"%s", org:"%s")`, bucketName, bucketName, orgName),
WantReadBuckets: &[]platform.BucketFilter{{Name: &bucketName}},
WantWriteBuckets: &[]platform.BucketFilter{{Name: &bucketName, Organization: &orgName}},
WantWriteBuckets: &[]platform.BucketFilter{{Name: &bucketName, Org: &orgName}},
},
{
Name: "from() with bucket and to with orgID and bucket",
Expand Down
4 changes: 2 additions & 2 deletions query/stdlib/testing/end_to_end_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func testFlux(t testing.TB, l *launcher.TestLauncher, pkg *ast.Package) {
// Query server to ensure write persists.

b := &platform.Bucket{
Organization: "ORG",
Org: "ORG",
Name: t.Name(),
RetentionPeriod: 0,
}
Expand All @@ -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.Organization},
Init: &ast.StringLiteral{Value: b.Org},
},
}
options := optionsAST.Copy().(*ast.File)
Expand Down
Loading

0 comments on commit 9d44ac3

Please sign in to comment.