diff --git a/bolt/client.go b/bolt/client.go index 50543c3a19..5b0ee2f67b 100644 --- a/bolt/client.go +++ b/bolt/client.go @@ -33,15 +33,16 @@ type Client struct { Now func() time.Time LayoutIDs chronograf.ID - BuildStore *BuildStore - SourcesStore *SourcesStore - ServersStore *ServersStore - LayoutsStore *LayoutsStore - DashboardsStore *DashboardsStore - UsersStore *UsersStore - OrganizationsStore *OrganizationsStore - ConfigStore *ConfigStore - MappingsStore *MappingsStore + BuildStore *BuildStore + SourcesStore *SourcesStore + ServersStore *ServersStore + LayoutsStore *LayoutsStore + DashboardsStore *DashboardsStore + UsersStore *UsersStore + OrganizationsStore *OrganizationsStore + ConfigStore *ConfigStore + MappingsStore *MappingsStore + OrganizationConfigStore *OrganizationConfigStore } // NewClient initializes all stores @@ -62,6 +63,7 @@ func NewClient() *Client { c.OrganizationsStore = &OrganizationsStore{client: c} c.ConfigStore = &ConfigStore{client: c} c.MappingsStore = &MappingsStore{client: c} + c.OrganizationConfigStore = &OrganizationConfigStore{client: c} return c } @@ -161,6 +163,10 @@ func (c *Client) initialize(ctx context.Context) error { if _, err := tx.CreateBucketIfNotExists(MappingsBucket); err != nil { return err } + // Always create OrganizationConfig bucket. + if _, err := tx.CreateBucketIfNotExists(OrganizationConfigBucket); err != nil { + return err + } return nil }); err != nil { return err @@ -197,6 +203,9 @@ func (c *Client) migrate(ctx context.Context, build chronograf.BuildInfo) error if err := c.MappingsStore.Migrate(ctx); err != nil { return err } + if err := c.OrganizationConfigStore.Migrate(ctx); err != nil { + return err + } MigrateAll(c) } diff --git a/bolt/internal/internal.go b/bolt/internal/internal.go index c64c852fa7..9795aaac9a 100644 --- a/bolt/internal/internal.go +++ b/bolt/internal/internal.go @@ -749,9 +749,9 @@ func UnmarshalConfigPB(data []byte, c *Config) error { // MarshalOrganizationConfig encodes a config to binary protobuf format. func MarshalOrganizationConfig(c *chronograf.OrganizationConfig) ([]byte, error) { - var lv chronograf.LogViewerConfig - columns := make([]*LogViewerColumn, len(lv.Columns)) - for i, column := range lv.Columns { + columns := make([]*LogViewerColumn, len(c.LogViewer.Columns)) + + for i, column := range c.LogViewer.Columns { encodings := make([]*ColumnEncoding, len(column.Encodings)) for j, e := range column.Encodings { @@ -768,7 +768,9 @@ func MarshalOrganizationConfig(c *chronograf.OrganizationConfig) ([]byte, error) Encodings: encodings, } } + return MarshalOrganizationConfigPB(&OrganizationConfig{ + OrganizationID: c.OrganizationID, LogViewer: &LogViewerConfig{ Columns: columns, }, @@ -783,13 +785,22 @@ func MarshalOrganizationConfigPB(c *OrganizationConfig) ([]byte, error) { // UnmarshalOrganizationConfig decodes a config from binary protobuf data. func UnmarshalOrganizationConfig(data []byte, c *chronograf.OrganizationConfig) error { var pb OrganizationConfig + if err := UnmarshalOrganizationConfigPB(data, &pb); err != nil { return err } + if pb.OrganizationID == "" { + return fmt.Errorf("Organization ID on organization config is nil") + } if pb.LogViewer == nil { return fmt.Errorf("Log Viewer config is nil") } + if pb.LogViewer.Columns == nil { + return fmt.Errorf("Log Viewer config Columns is nil") + } + + c.OrganizationID = pb.OrganizationID columns := make([]chronograf.LogViewerColumn, len(pb.LogViewer.Columns)) diff --git a/bolt/internal/internal.pb.go b/bolt/internal/internal.pb.go index 697f5e7edd..d39cbdc84b 100644 --- a/bolt/internal/internal.pb.go +++ b/bolt/internal/internal.pb.go @@ -1,6 +1,5 @@ -// Code generated by protoc-gen-gogo. +// Code generated by protoc-gen-gogo. DO NOT EDIT. // source: internal.proto -// DO NOT EDIT! /* Package internal is a generated protocol buffer package. @@ -79,6 +78,104 @@ func (m *Source) String() string { return proto.CompactTextString(m) func (*Source) ProtoMessage() {} func (*Source) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{0} } +func (m *Source) GetID() int64 { + if m != nil { + return m.ID + } + return 0 +} + +func (m *Source) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Source) GetType() string { + if m != nil { + return m.Type + } + return "" +} + +func (m *Source) GetUsername() string { + if m != nil { + return m.Username + } + return "" +} + +func (m *Source) GetPassword() string { + if m != nil { + return m.Password + } + return "" +} + +func (m *Source) GetURL() string { + if m != nil { + return m.URL + } + return "" +} + +func (m *Source) GetDefault() bool { + if m != nil { + return m.Default + } + return false +} + +func (m *Source) GetTelegraf() string { + if m != nil { + return m.Telegraf + } + return "" +} + +func (m *Source) GetInsecureSkipVerify() bool { + if m != nil { + return m.InsecureSkipVerify + } + return false +} + +func (m *Source) GetMetaURL() string { + if m != nil { + return m.MetaURL + } + return "" +} + +func (m *Source) GetSharedSecret() string { + if m != nil { + return m.SharedSecret + } + return "" +} + +func (m *Source) GetOrganization() string { + if m != nil { + return m.Organization + } + return "" +} + +func (m *Source) GetRole() string { + if m != nil { + return m.Role + } + return "" +} + +func (m *Source) GetDefaultRP() string { + if m != nil { + return m.DefaultRP + } + return "" +} + type Dashboard struct { ID int64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"` Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"` @@ -92,6 +189,20 @@ func (m *Dashboard) String() string { return proto.CompactTextString( func (*Dashboard) ProtoMessage() {} func (*Dashboard) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{1} } +func (m *Dashboard) GetID() int64 { + if m != nil { + return m.ID + } + return 0 +} + +func (m *Dashboard) GetName() string { + if m != nil { + return m.Name + } + return "" +} + func (m *Dashboard) GetCells() []*DashboardCell { if m != nil { return m.Cells @@ -106,6 +217,13 @@ func (m *Dashboard) GetTemplates() []*Template { return nil } +func (m *Dashboard) GetOrganization() string { + if m != nil { + return m.Organization + } + return "" +} + type DashboardCell struct { X int32 `protobuf:"varint,1,opt,name=x,proto3" json:"x,omitempty"` Y int32 `protobuf:"varint,2,opt,name=y,proto3" json:"y,omitempty"` @@ -129,6 +247,34 @@ func (m *DashboardCell) String() string { return proto.CompactTextStr func (*DashboardCell) ProtoMessage() {} func (*DashboardCell) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{2} } +func (m *DashboardCell) GetX() int32 { + if m != nil { + return m.X + } + return 0 +} + +func (m *DashboardCell) GetY() int32 { + if m != nil { + return m.Y + } + return 0 +} + +func (m *DashboardCell) GetW() int32 { + if m != nil { + return m.W + } + return 0 +} + +func (m *DashboardCell) GetH() int32 { + if m != nil { + return m.H + } + return 0 +} + func (m *DashboardCell) GetQueries() []*Query { if m != nil { return m.Queries @@ -136,6 +282,27 @@ func (m *DashboardCell) GetQueries() []*Query { return nil } +func (m *DashboardCell) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *DashboardCell) GetType() string { + if m != nil { + return m.Type + } + return "" +} + +func (m *DashboardCell) GetID() string { + if m != nil { + return m.ID + } + return "" +} + func (m *DashboardCell) GetAxes() map[string]*Axis { if m != nil { return m.Axes @@ -171,6 +338,13 @@ func (m *DashboardCell) GetFieldOptions() []*RenamableField { return nil } +func (m *DashboardCell) GetTimeFormat() string { + if m != nil { + return m.TimeFormat + } + return "" +} + func (m *DashboardCell) GetDecimalPlaces() *DecimalPlaces { if m != nil { return m.DecimalPlaces @@ -188,6 +362,20 @@ func (m *DecimalPlaces) String() string { return proto.CompactTextStr func (*DecimalPlaces) ProtoMessage() {} func (*DecimalPlaces) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{3} } +func (m *DecimalPlaces) GetIsEnforced() bool { + if m != nil { + return m.IsEnforced + } + return false +} + +func (m *DecimalPlaces) GetDigits() int32 { + if m != nil { + return m.Digits + } + return 0 +} + type TableOptions struct { VerticalTimeAxis bool `protobuf:"varint,2,opt,name=verticalTimeAxis,proto3" json:"verticalTimeAxis,omitempty"` SortBy *RenamableField `protobuf:"bytes,3,opt,name=sortBy" json:"sortBy,omitempty"` @@ -200,6 +388,13 @@ func (m *TableOptions) String() string { return proto.CompactTextStri func (*TableOptions) ProtoMessage() {} func (*TableOptions) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{4} } +func (m *TableOptions) GetVerticalTimeAxis() bool { + if m != nil { + return m.VerticalTimeAxis + } + return false +} + func (m *TableOptions) GetSortBy() *RenamableField { if m != nil { return m.SortBy @@ -207,6 +402,20 @@ func (m *TableOptions) GetSortBy() *RenamableField { return nil } +func (m *TableOptions) GetWrapping() string { + if m != nil { + return m.Wrapping + } + return "" +} + +func (m *TableOptions) GetFixFirstColumn() bool { + if m != nil { + return m.FixFirstColumn + } + return false +} + type RenamableField struct { InternalName string `protobuf:"bytes,1,opt,name=internalName,proto3" json:"internalName,omitempty"` DisplayName string `protobuf:"bytes,2,opt,name=displayName,proto3" json:"displayName,omitempty"` @@ -218,6 +427,27 @@ func (m *RenamableField) String() string { return proto.CompactTextSt func (*RenamableField) ProtoMessage() {} func (*RenamableField) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{5} } +func (m *RenamableField) GetInternalName() string { + if m != nil { + return m.InternalName + } + return "" +} + +func (m *RenamableField) GetDisplayName() string { + if m != nil { + return m.DisplayName + } + return "" +} + +func (m *RenamableField) GetVisible() bool { + if m != nil { + return m.Visible + } + return false +} + type Color struct { ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"` Type string `protobuf:"bytes,2,opt,name=Type,proto3" json:"Type,omitempty"` @@ -231,6 +461,41 @@ func (m *Color) String() string { return proto.CompactTextString(m) } func (*Color) ProtoMessage() {} func (*Color) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{6} } +func (m *Color) GetID() string { + if m != nil { + return m.ID + } + return "" +} + +func (m *Color) GetType() string { + if m != nil { + return m.Type + } + return "" +} + +func (m *Color) GetHex() string { + if m != nil { + return m.Hex + } + return "" +} + +func (m *Color) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Color) GetValue() string { + if m != nil { + return m.Value + } + return "" +} + type Legend struct { Type string `protobuf:"bytes,1,opt,name=Type,proto3" json:"Type,omitempty"` Orientation string `protobuf:"bytes,2,opt,name=Orientation,proto3" json:"Orientation,omitempty"` @@ -241,8 +506,22 @@ func (m *Legend) String() string { return proto.CompactTextString(m) func (*Legend) ProtoMessage() {} func (*Legend) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{7} } +func (m *Legend) GetType() string { + if m != nil { + return m.Type + } + return "" +} + +func (m *Legend) GetOrientation() string { + if m != nil { + return m.Orientation + } + return "" +} + type Axis struct { - LegacyBounds []int64 `protobuf:"varint,1,rep,name=legacyBounds" json:"legacyBounds,omitempty"` + LegacyBounds []int64 `protobuf:"varint,1,rep,packed,name=legacyBounds" json:"legacyBounds,omitempty"` Bounds []string `protobuf:"bytes,2,rep,name=bounds" json:"bounds,omitempty"` Label string `protobuf:"bytes,3,opt,name=label,proto3" json:"label,omitempty"` Prefix string `protobuf:"bytes,4,opt,name=prefix,proto3" json:"prefix,omitempty"` @@ -256,6 +535,55 @@ func (m *Axis) String() string { return proto.CompactTextString(m) } func (*Axis) ProtoMessage() {} func (*Axis) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{8} } +func (m *Axis) GetLegacyBounds() []int64 { + if m != nil { + return m.LegacyBounds + } + return nil +} + +func (m *Axis) GetBounds() []string { + if m != nil { + return m.Bounds + } + return nil +} + +func (m *Axis) GetLabel() string { + if m != nil { + return m.Label + } + return "" +} + +func (m *Axis) GetPrefix() string { + if m != nil { + return m.Prefix + } + return "" +} + +func (m *Axis) GetSuffix() string { + if m != nil { + return m.Suffix + } + return "" +} + +func (m *Axis) GetBase() string { + if m != nil { + return m.Base + } + return "" +} + +func (m *Axis) GetScale() string { + if m != nil { + return m.Scale + } + return "" +} + type Template struct { ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"` TempVar string `protobuf:"bytes,2,opt,name=temp_var,json=tempVar,proto3" json:"temp_var,omitempty"` @@ -270,6 +598,20 @@ func (m *Template) String() string { return proto.CompactTextString(m func (*Template) ProtoMessage() {} func (*Template) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{9} } +func (m *Template) GetID() string { + if m != nil { + return m.ID + } + return "" +} + +func (m *Template) GetTempVar() string { + if m != nil { + return m.TempVar + } + return "" +} + func (m *Template) GetValues() []*TemplateValue { if m != nil { return m.Values @@ -277,6 +619,20 @@ func (m *Template) GetValues() []*TemplateValue { return nil } +func (m *Template) GetType() string { + if m != nil { + return m.Type + } + return "" +} + +func (m *Template) GetLabel() string { + if m != nil { + return m.Label + } + return "" +} + func (m *Template) GetQuery() *TemplateQuery { if m != nil { return m.Query @@ -296,6 +652,34 @@ func (m *TemplateValue) String() string { return proto.CompactTextStr func (*TemplateValue) ProtoMessage() {} func (*TemplateValue) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{10} } +func (m *TemplateValue) GetType() string { + if m != nil { + return m.Type + } + return "" +} + +func (m *TemplateValue) GetValue() string { + if m != nil { + return m.Value + } + return "" +} + +func (m *TemplateValue) GetSelected() bool { + if m != nil { + return m.Selected + } + return false +} + +func (m *TemplateValue) GetKey() string { + if m != nil { + return m.Key + } + return "" +} + type TemplateQuery struct { Command string `protobuf:"bytes,1,opt,name=command,proto3" json:"command,omitempty"` Db string `protobuf:"bytes,2,opt,name=db,proto3" json:"db,omitempty"` @@ -310,6 +694,48 @@ func (m *TemplateQuery) String() string { return proto.CompactTextStr func (*TemplateQuery) ProtoMessage() {} func (*TemplateQuery) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{11} } +func (m *TemplateQuery) GetCommand() string { + if m != nil { + return m.Command + } + return "" +} + +func (m *TemplateQuery) GetDb() string { + if m != nil { + return m.Db + } + return "" +} + +func (m *TemplateQuery) GetRp() string { + if m != nil { + return m.Rp + } + return "" +} + +func (m *TemplateQuery) GetMeasurement() string { + if m != nil { + return m.Measurement + } + return "" +} + +func (m *TemplateQuery) GetTagKey() string { + if m != nil { + return m.TagKey + } + return "" +} + +func (m *TemplateQuery) GetFieldKey() string { + if m != nil { + return m.FieldKey + } + return "" +} + type Server struct { ID int64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"` Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"` @@ -329,6 +755,83 @@ func (m *Server) String() string { return proto.CompactTextString(m) func (*Server) ProtoMessage() {} func (*Server) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{12} } +func (m *Server) GetID() int64 { + if m != nil { + return m.ID + } + return 0 +} + +func (m *Server) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Server) GetUsername() string { + if m != nil { + return m.Username + } + return "" +} + +func (m *Server) GetPassword() string { + if m != nil { + return m.Password + } + return "" +} + +func (m *Server) GetURL() string { + if m != nil { + return m.URL + } + return "" +} + +func (m *Server) GetSrcID() int64 { + if m != nil { + return m.SrcID + } + return 0 +} + +func (m *Server) GetActive() bool { + if m != nil { + return m.Active + } + return false +} + +func (m *Server) GetOrganization() string { + if m != nil { + return m.Organization + } + return "" +} + +func (m *Server) GetInsecureSkipVerify() bool { + if m != nil { + return m.InsecureSkipVerify + } + return false +} + +func (m *Server) GetType() string { + if m != nil { + return m.Type + } + return "" +} + +func (m *Server) GetMetadataJSON() string { + if m != nil { + return m.MetadataJSON + } + return "" +} + type Layout struct { ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"` Application string `protobuf:"bytes,2,opt,name=Application,proto3" json:"Application,omitempty"` @@ -342,6 +845,27 @@ func (m *Layout) String() string { return proto.CompactTextString(m) func (*Layout) ProtoMessage() {} func (*Layout) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{13} } +func (m *Layout) GetID() string { + if m != nil { + return m.ID + } + return "" +} + +func (m *Layout) GetApplication() string { + if m != nil { + return m.Application + } + return "" +} + +func (m *Layout) GetMeasurement() string { + if m != nil { + return m.Measurement + } + return "" +} + func (m *Layout) GetCells() []*Cell { if m != nil { return m.Cells @@ -349,6 +873,13 @@ func (m *Layout) GetCells() []*Cell { return nil } +func (m *Layout) GetAutoflow() bool { + if m != nil { + return m.Autoflow + } + return false +} + type Cell struct { X int32 `protobuf:"varint,1,opt,name=x,proto3" json:"x,omitempty"` Y int32 `protobuf:"varint,2,opt,name=y,proto3" json:"y,omitempty"` @@ -357,7 +888,7 @@ type Cell struct { Queries []*Query `protobuf:"bytes,5,rep,name=queries" json:"queries,omitempty"` I string `protobuf:"bytes,6,opt,name=i,proto3" json:"i,omitempty"` Name string `protobuf:"bytes,7,opt,name=name,proto3" json:"name,omitempty"` - Yranges []int64 `protobuf:"varint,8,rep,name=yranges" json:"yranges,omitempty"` + Yranges []int64 `protobuf:"varint,8,rep,packed,name=yranges" json:"yranges,omitempty"` Ylabels []string `protobuf:"bytes,9,rep,name=ylabels" json:"ylabels,omitempty"` Type string `protobuf:"bytes,10,opt,name=type,proto3" json:"type,omitempty"` Axes map[string]*Axis `protobuf:"bytes,11,rep,name=axes" json:"axes,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value"` @@ -368,6 +899,34 @@ func (m *Cell) String() string { return proto.CompactTextString(m) } func (*Cell) ProtoMessage() {} func (*Cell) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{14} } +func (m *Cell) GetX() int32 { + if m != nil { + return m.X + } + return 0 +} + +func (m *Cell) GetY() int32 { + if m != nil { + return m.Y + } + return 0 +} + +func (m *Cell) GetW() int32 { + if m != nil { + return m.W + } + return 0 +} + +func (m *Cell) GetH() int32 { + if m != nil { + return m.H + } + return 0 +} + func (m *Cell) GetQueries() []*Query { if m != nil { return m.Queries @@ -375,6 +934,41 @@ func (m *Cell) GetQueries() []*Query { return nil } +func (m *Cell) GetI() string { + if m != nil { + return m.I + } + return "" +} + +func (m *Cell) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Cell) GetYranges() []int64 { + if m != nil { + return m.Yranges + } + return nil +} + +func (m *Cell) GetYlabels() []string { + if m != nil { + return m.Ylabels + } + return nil +} + +func (m *Cell) GetType() string { + if m != nil { + return m.Type + } + return "" +} + func (m *Cell) GetAxes() map[string]*Axis { if m != nil { return m.Axes @@ -399,6 +993,48 @@ func (m *Query) String() string { return proto.CompactTextString(m) } func (*Query) ProtoMessage() {} func (*Query) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{15} } +func (m *Query) GetCommand() string { + if m != nil { + return m.Command + } + return "" +} + +func (m *Query) GetDB() string { + if m != nil { + return m.DB + } + return "" +} + +func (m *Query) GetRP() string { + if m != nil { + return m.RP + } + return "" +} + +func (m *Query) GetGroupBys() []string { + if m != nil { + return m.GroupBys + } + return nil +} + +func (m *Query) GetWheres() []string { + if m != nil { + return m.Wheres + } + return nil +} + +func (m *Query) GetLabel() string { + if m != nil { + return m.Label + } + return "" +} + func (m *Query) GetRange() *Range { if m != nil { return m.Range @@ -406,6 +1042,13 @@ func (m *Query) GetRange() *Range { return nil } +func (m *Query) GetSource() string { + if m != nil { + return m.Source + } + return "" +} + func (m *Query) GetShifts() []*TimeShift { if m != nil { return m.Shifts @@ -424,6 +1067,27 @@ func (m *TimeShift) String() string { return proto.CompactTextString( func (*TimeShift) ProtoMessage() {} func (*TimeShift) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{16} } +func (m *TimeShift) GetLabel() string { + if m != nil { + return m.Label + } + return "" +} + +func (m *TimeShift) GetUnit() string { + if m != nil { + return m.Unit + } + return "" +} + +func (m *TimeShift) GetQuantity() string { + if m != nil { + return m.Quantity + } + return "" +} + type Range struct { Upper int64 `protobuf:"varint,1,opt,name=Upper,proto3" json:"Upper,omitempty"` Lower int64 `protobuf:"varint,2,opt,name=Lower,proto3" json:"Lower,omitempty"` @@ -434,6 +1098,20 @@ func (m *Range) String() string { return proto.CompactTextString(m) } func (*Range) ProtoMessage() {} func (*Range) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{17} } +func (m *Range) GetUpper() int64 { + if m != nil { + return m.Upper + } + return 0 +} + +func (m *Range) GetLower() int64 { + if m != nil { + return m.Lower + } + return 0 +} + type AlertRule struct { ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"` JSON string `protobuf:"bytes,2,opt,name=JSON,proto3" json:"JSON,omitempty"` @@ -446,6 +1124,34 @@ func (m *AlertRule) String() string { return proto.CompactTextString( func (*AlertRule) ProtoMessage() {} func (*AlertRule) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{18} } +func (m *AlertRule) GetID() string { + if m != nil { + return m.ID + } + return "" +} + +func (m *AlertRule) GetJSON() string { + if m != nil { + return m.JSON + } + return "" +} + +func (m *AlertRule) GetSrcID() int64 { + if m != nil { + return m.SrcID + } + return 0 +} + +func (m *AlertRule) GetKapaID() int64 { + if m != nil { + return m.KapaID + } + return 0 +} + type User struct { ID uint64 `protobuf:"varint,1,opt,name=ID,proto3" json:"ID,omitempty"` Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"` @@ -460,6 +1166,34 @@ func (m *User) String() string { return proto.CompactTextString(m) } func (*User) ProtoMessage() {} func (*User) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{19} } +func (m *User) GetID() uint64 { + if m != nil { + return m.ID + } + return 0 +} + +func (m *User) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *User) GetProvider() string { + if m != nil { + return m.Provider + } + return "" +} + +func (m *User) GetScheme() string { + if m != nil { + return m.Scheme + } + return "" +} + func (m *User) GetRoles() []*Role { if m != nil { return m.Roles @@ -467,6 +1201,13 @@ func (m *User) GetRoles() []*Role { return nil } +func (m *User) GetSuperAdmin() bool { + if m != nil { + return m.SuperAdmin + } + return false +} + type Role struct { Organization string `protobuf:"bytes,1,opt,name=Organization,proto3" json:"Organization,omitempty"` Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"` @@ -477,6 +1218,20 @@ func (m *Role) String() string { return proto.CompactTextString(m) } func (*Role) ProtoMessage() {} func (*Role) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{20} } +func (m *Role) GetOrganization() string { + if m != nil { + return m.Organization + } + return "" +} + +func (m *Role) GetName() string { + if m != nil { + return m.Name + } + return "" +} + type Mapping struct { Provider string `protobuf:"bytes,1,opt,name=Provider,proto3" json:"Provider,omitempty"` Scheme string `protobuf:"bytes,2,opt,name=Scheme,proto3" json:"Scheme,omitempty"` @@ -490,6 +1245,41 @@ func (m *Mapping) String() string { return proto.CompactTextString(m) func (*Mapping) ProtoMessage() {} func (*Mapping) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{21} } +func (m *Mapping) GetProvider() string { + if m != nil { + return m.Provider + } + return "" +} + +func (m *Mapping) GetScheme() string { + if m != nil { + return m.Scheme + } + return "" +} + +func (m *Mapping) GetProviderOrganization() string { + if m != nil { + return m.ProviderOrganization + } + return "" +} + +func (m *Mapping) GetID() string { + if m != nil { + return m.ID + } + return "" +} + +func (m *Mapping) GetOrganization() string { + if m != nil { + return m.Organization + } + return "" +} + type Organization struct { ID string `protobuf:"bytes,1,opt,name=ID,proto3" json:"ID,omitempty"` Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"` @@ -501,6 +1291,27 @@ func (m *Organization) String() string { return proto.CompactTextStri func (*Organization) ProtoMessage() {} func (*Organization) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{22} } +func (m *Organization) GetID() string { + if m != nil { + return m.ID + } + return "" +} + +func (m *Organization) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Organization) GetDefaultRole() string { + if m != nil { + return m.DefaultRole + } + return "" +} + type Config struct { Auth *AuthConfig `protobuf:"bytes,1,opt,name=Auth" json:"Auth,omitempty"` } @@ -526,8 +1337,16 @@ func (m *AuthConfig) String() string { return proto.CompactTextString func (*AuthConfig) ProtoMessage() {} func (*AuthConfig) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{24} } +func (m *AuthConfig) GetSuperAdminNewUsers() bool { + if m != nil { + return m.SuperAdminNewUsers + } + return false +} + type OrganizationConfig struct { - LogViewer *LogViewerConfig `protobuf:"bytes,1,opt,name=LogViewer" json:"LogViewer,omitempty"` + OrganizationID string `protobuf:"bytes,1,opt,name=OrganizationID,proto3" json:"OrganizationID,omitempty"` + LogViewer *LogViewerConfig `protobuf:"bytes,2,opt,name=LogViewer" json:"LogViewer,omitempty"` } func (m *OrganizationConfig) Reset() { *m = OrganizationConfig{} } @@ -535,6 +1354,13 @@ func (m *OrganizationConfig) String() string { return proto.CompactTe func (*OrganizationConfig) ProtoMessage() {} func (*OrganizationConfig) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{25} } +func (m *OrganizationConfig) GetOrganizationID() string { + if m != nil { + return m.OrganizationID + } + return "" +} + func (m *OrganizationConfig) GetLogViewer() *LogViewerConfig { if m != nil { return m.LogViewer @@ -569,6 +1395,20 @@ func (m *LogViewerColumn) String() string { return proto.CompactTextS func (*LogViewerColumn) ProtoMessage() {} func (*LogViewerColumn) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{27} } +func (m *LogViewerColumn) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *LogViewerColumn) GetPosition() int32 { + if m != nil { + return m.Position + } + return 0 +} + func (m *LogViewerColumn) GetEncodings() []*ColumnEncoding { if m != nil { return m.Encodings @@ -587,6 +1427,27 @@ func (m *ColumnEncoding) String() string { return proto.CompactTextSt func (*ColumnEncoding) ProtoMessage() {} func (*ColumnEncoding) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{28} } +func (m *ColumnEncoding) GetType() string { + if m != nil { + return m.Type + } + return "" +} + +func (m *ColumnEncoding) GetValue() string { + if m != nil { + return m.Value + } + return "" +} + +func (m *ColumnEncoding) GetName() string { + if m != nil { + return m.Name + } + return "" +} + type BuildInfo struct { Version string `protobuf:"bytes,1,opt,name=Version,proto3" json:"Version,omitempty"` Commit string `protobuf:"bytes,2,opt,name=Commit,proto3" json:"Commit,omitempty"` @@ -597,6 +1458,20 @@ func (m *BuildInfo) String() string { return proto.CompactTextString( func (*BuildInfo) ProtoMessage() {} func (*BuildInfo) Descriptor() ([]byte, []int) { return fileDescriptorInternal, []int{29} } +func (m *BuildInfo) GetVersion() string { + if m != nil { + return m.Version + } + return "" +} + +func (m *BuildInfo) GetCommit() string { + if m != nil { + return m.Commit + } + return "" +} + func init() { proto.RegisterType((*Source)(nil), "internal.Source") proto.RegisterType((*Dashboard)(nil), "internal.Dashboard") @@ -633,118 +1508,118 @@ func init() { func init() { proto.RegisterFile("internal.proto", fileDescriptorInternal) } var fileDescriptorInternal = []byte{ - // 1798 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xbc, 0x58, 0xdd, 0x6f, 0xe4, 0x48, - 0x11, 0x97, 0x67, 0xec, 0xc9, 0xb8, 0x26, 0xc9, 0x46, 0xcd, 0xea, 0xce, 0x77, 0x20, 0x34, 0x58, - 0x7c, 0x84, 0x8f, 0x5b, 0x4e, 0x59, 0xf1, 0xa1, 0xd3, 0xdd, 0x49, 0xf9, 0xd8, 0x5d, 0xb2, 0x9f, - 0xd9, 0x4e, 0x36, 0x3c, 0xa1, 0x53, 0xc7, 0xee, 0x99, 0xb4, 0xce, 0x63, 0x9b, 0xb6, 0x9d, 0xc4, - 0x3c, 0xf3, 0x77, 0x20, 0x21, 0xc1, 0x3b, 0x42, 0x3c, 0x22, 0xf1, 0xce, 0x1f, 0xc0, 0xbf, 0xc2, - 0x2b, 0xaa, 0xfe, 0xb0, 0xdb, 0xc9, 0xec, 0x6a, 0x91, 0x10, 0x6f, 0xfd, 0xab, 0xaa, 0xa9, 0xae, - 0xae, 0xae, 0xfa, 0x75, 0x79, 0x60, 0x5b, 0xe4, 0x35, 0x97, 0x39, 0xcb, 0x1e, 0x94, 0xb2, 0xa8, - 0x0b, 0x32, 0xb5, 0x38, 0xfe, 0xfd, 0x18, 0x26, 0xa7, 0x45, 0x23, 0x13, 0x4e, 0xb6, 0x61, 0x74, - 0x7c, 0x14, 0x79, 0x73, 0x6f, 0x77, 0x4c, 0x47, 0xc7, 0x47, 0x84, 0x80, 0xff, 0x92, 0xad, 0x78, - 0x34, 0x9a, 0x7b, 0xbb, 0x21, 0x55, 0x6b, 0x94, 0x9d, 0xb5,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0x1f, 0xb4, 0xaa, 0x6a, 0xdf, - 0x95, 0x65, 0x63, 0x87, 0x3c, 0x75, 0x2d, 0x59, 0x59, 0x8a, 0x7c, 0x69, 0xb9, 0xd0, 0x62, 0xf2, - 0x7d, 0xd8, 0x5e, 0x88, 0x9b, 0xc7, 0x42, 0x56, 0xf5, 0x61, 0x91, 0x35, 0xab, 0x5c, 0x55, 0xf0, - 0x94, 0xde, 0x92, 0x3e, 0xf5, 0xa7, 0xde, 0xce, 0xe8, 0xa9, 0x3f, 0x0d, 0x76, 0x26, 0x71, 0x09, - 0xdb, 0xc3, 0x9d, 0xb0, 0x2d, 0x6d, 0x10, 0x8a, 0x13, 0x74, 0x7a, 0x07, 0x32, 0x32, 0x87, 0x59, - 0x2a, 0xaa, 0x32, 0x63, 0xad, 0x43, 0x1b, 0xae, 0x08, 0x39, 0xf0, 0x4a, 0x54, 0xe2, 0x22, 0xd3, - 0x54, 0x3e, 0xa5, 0x16, 0xc6, 0x4b, 0x08, 0x54, 0x59, 0x3b, 0x24, 0x14, 0x5a, 0x12, 0x52, 0xd4, - 0x3f, 0x72, 0xa8, 0x7f, 0x07, 0xc6, 0xbf, 0xe2, 0x37, 0xe6, 0x35, 0xc0, 0x65, 0x47, 0x55, 0xbe, - 0x43, 0x55, 0xf7, 0x21, 0x38, 0x57, 0xd7, 0xae, 0x29, 0x44, 0x83, 0xf8, 0x4b, 0x98, 0xe8, 0xb6, - 0xe8, 0x3c, 0x7b, 0x8e, 0xe7, 0x39, 0xcc, 0x5e, 0x49, 0xc1, 0xf3, 0x5a, 0x93, 0x8f, 0x39, 0x82, - 0x23, 0x8a, 0xff, 0xea, 0x81, 0xaf, 0x6e, 0x29, 0x86, 0xcd, 0x8c, 0x2f, 0x59, 0xd2, 0x1e, 0x14, - 0x4d, 0x9e, 0x56, 0x91, 0x37, 0x1f, 0xef, 0x8e, 0xe9, 0x40, 0x86, 0xe5, 0x71, 0xa1, 0xb5, 0xa3, - 0xf9, 0x78, 0x37,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x4b, 0x38, - 0xaf, 0x54, 0x5a, 0x12, 0x00, 0x00, + // 1807 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0x4b, 0x6f, 0xdc, 0xc8, + 0x11, 0x06, 0x67, 0x86, 0xa3, 0x61, 0x8d, 0x24, 0x0b, 0x1d, 0x63, 0x97, 0xbb, 0x09, 0x82, 0x09, + 0x91, 0x6c, 0x94, 0xc7, 0x3a, 0x0b, 0x19, 0x79, 0x60, 0xb1, 0xbb, 0x80, 0x1e, 0xb6, 0x23, 0x5b, + 0xb6, 0xe5, 0x96, 0xac, 0x9c, 0x82, 0x45, 0x8b, 0xec, 0x99, 0x69, 0x98, 0x43, 0x32, 0x4d, 0x52, + 0x12, 0x73, 0xce, 0xef, 0x08, 0x10, 0x20, 0xb9, 0x07, 0x41, 0x8e, 0x01, 0x72, 0xcf, 0x0f, 0xc8, + 0x5f, 0xc9, 0x35, 0xa8, 0x7e, 0x90, 0x4d, 0x69, 0x6c, 0x38, 0x40, 0xb0, 0xb7, 0xfe, 0xaa, 0x6a, + 0xaa, 0xab, 0xab, 0xab, 0xbe, 0x2e, 0x0e, 0x6c, 0x8b, 0xac, 0xe2, 0x32, 0x63, 0xe9, 0x83, 0x42, + 0xe6, 0x55, 0x4e, 0x26, 0x16, 0x47, 0x7f, 0x18, 0xc2, 0xf8, 0x2c, 0xaf, 0x65, 0xcc, 0xc9, 0x36, + 0x0c, 0x8e, 0x8f, 0x42, 0x6f, 0xe6, 0xed, 0x0e, 0xe9, 0xe0, 0xf8, 0x88, 0x10, 0x18, 0xbd, 0x60, + 0x2b, 0x1e, 0x0e, 0x66, 0xde, 0x6e, 0x40, 0xd5, 0x1a, 0x65, 0xe7, 0x4d, 0xc1, 0xc3, 0xa1, 0x96, + 0xe1, 0x9a, 0x7c, 0x0c, 0x93, 0xd7, 0x25, 0x7a, 0x5b, 0xf1, 0x70, 0xa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internal/internal.proto b/bolt/internal/internal.proto index a4d8346996..959cb5e72f 100644 --- a/bolt/internal/internal.proto +++ b/bolt/internal/internal.proto @@ -215,7 +215,8 @@ message AuthConfig { } message OrganizationConfig { - LogViewerConfig LogViewer = 1; // LogViewer is the organization configuration for log viewer + string OrganizationID = 1; // OrganizationID is the ID of the organization this config belogs to + LogViewerConfig LogViewer = 2; // LogViewer is the organization configuration for log viewer } message LogViewerConfig { diff --git a/bolt/org_config.go b/bolt/org_config.go index 3fe011305f..56f8dce5f1 100644 --- a/bolt/org_config.go +++ b/bolt/org_config.go @@ -12,145 +12,26 @@ import ( // Ensure OrganizationConfigStore implements chronograf.OrganizationConfigStore. var _ chronograf.OrganizationConfigStore = &OrganizationConfigStore{} -// ConfigBucket is used to store chronograf application state -var ConfigBucket = []byte("ConfigV1") +// OrganizationConfigBucket is used to store chronograf organization configurations +var OrganizationConfigBucket = []byte("OrganizationConfigV1") -// configID is the boltDB key where the configuration object is stored -var configID = []byte("config/v1") - -// OrganizationConfigStore uses bolt to store and retrieve global -// application configuration +// OrganizationConfigStore uses bolt to store and retrieve organization configurations type OrganizationConfigStore struct { client *Client } func (s *OrganizationConfigStore) Migrate(ctx context.Context) error { - if _, err := s.Get(ctx); err != nil { - return s.Initialize(ctx) - } return nil } -func (s *OrganizationConfigStore) Initialize(ctx context.Context) error { - cfg := chronograf.OrganizationConfig{ - OrganizationConfig: chronograf.OrganizationConfig{ - - LogViewer: chronograf.LogViewer{ - Columns: []chronograf.LogViewerColumn{ - { - Name: "time", - Position: 0, - Encodings: []chronograf.ColumnEncoding{ - { - Type: "visibility", - Value: "hidden", - }, - }, - }, - { - Name: "severity", - Position: 1, - Encodings: []chronograf.ColumnEncoding{ - - { - Type: "visibility", - Value: "visible", - }, - { - Type: "label", - Value: "icon", - }, - { - Type: "label", - Value: "text", - }, - }, - }, - { - Name: "timestamp", - Position: 2, - Encodings: []chronograf.ColumnEncoding{ - - { - Type: "visibility", - Value: "visible", - }, - }, - }, - { - Name: "message", - Position: 3, - Encodings: []chronograf.ColumnEncoding{ - - { - Type: "visibility", - Value: "visible", - }, - }, - }, - { - Name: "facility", - Position: 4, - Encodings: []chronograf.ColumnEncoding{ - - { - Type: "visibility", - Value: "visible", - }, - }, - }, - { - Name: "procid", - Position: 5, - Encodings: []chronograf.ColumnEncoding{ - - { - Type: "visibility", - Value: "visible", - }, - { - Type: "displayName", - Value: "Proc ID", - }, - }, - }, - { - Name: "appname", - Position: 6, - Encodings: []chronograf.ColumnEncoding{ - { - Type: "visibility", - Value: "visible", - }, - { - Type: "displayName", - Value: "Application", - }, - }, - }, - { - Name: "host", - Position: 7, - Encodings: []chronograf.ColumnEncoding{ - { - Type: "visibility", - Value: "visible", - }, - }, - }, - }, - }, - }, - } - return s.Update(ctx, &cfg) -} - -func (s *OrganizationConfigStore) Get(ctx context.Context) (*chronograf.OrganizationConfig, error) { +// FindOrCreate gets an OrganizationConfig from the store or creates one if none exists for this organization +func (s *OrganizationConfigStore) FindOrCreate(ctx context.Context, orgID string) (*chronograf.OrganizationConfig, error) { var cfg chronograf.OrganizationConfig err := s.client.db.View(func(tx *bolt.Tx) error { - v := tx.Bucket(ConfigBucket).Get(configID) + v := tx.Bucket(OrganizationConfigBucket).Get([]byte(orgID)) if v == nil { - return chronograf.ErrConfigNotFound + cfg = newOrganizationConfig(orgID) + return nil } return internal.UnmarshalOrganizationConfig(v, &cfg) }) @@ -161,6 +42,7 @@ func (s *OrganizationConfigStore) Get(ctx context.Context) (*chronograf.Organiza return &cfg, nil } +// Update replaces the OrganizationConfig in the store func (s *OrganizationConfigStore) Update(ctx context.Context, cfg *chronograf.OrganizationConfig) error { if cfg == nil { return fmt.Errorf("config provided was nil") @@ -168,9 +50,120 @@ func (s *OrganizationConfigStore) Update(ctx context.Context, cfg *chronograf.Or return s.client.db.Update(func(tx *bolt.Tx) error { if v, err := internal.MarshalOrganizationConfig(cfg); err != nil { return err - } else if err := tx.Bucket(ConfigBucket).Put(configID, v); err != nil { + } else if err := tx.Bucket(OrganizationConfigBucket).Put([]byte(cfg.OrganizationID), v); err != nil { return err } return nil }) } + +func newOrganizationConfig(orgID string) chronograf.OrganizationConfig { + return chronograf.OrganizationConfig{ + OrganizationID: orgID, + LogViewer: chronograf.LogViewerConfig{ + Columns: []chronograf.LogViewerColumn{ + { + Name: "time", + Position: 0, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "visibility", + Value: "hidden", + }, + }, + }, + { + Name: "severity", + Position: 1, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + { + Type: "label", + Value: "icon", + }, + { + Type: "label", + Value: "text", + }, + }, + }, + { + Name: "timestamp", + Position: 2, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + }, + }, + { + Name: "message", + Position: 3, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + }, + }, + { + Name: "facility", + Position: 4, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + }, + }, + { + Name: "procid", + Position: 5, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + { + Type: "displayName", + Value: "Proc ID", + }, + }, + }, + { + Name: "appname", + Position: 6, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "visibility", + Value: "visible", + }, + { + Type: "displayName", + Value: "Application", + }, + }, + }, + { + Name: "host", + Position: 7, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "visibility", + Value: "visible", + }, + }, + }, + }, + }, + } +} diff --git a/bolt/org_config_test.go b/bolt/org_config_test.go index 2fafd45f71..4e6a1ff38c 100644 --- a/bolt/org_config_test.go +++ b/bolt/org_config_test.go @@ -8,19 +8,29 @@ import ( "github.com/influxdata/chronograf" ) -func TestConfig_Get(t *testing.T) { +func TestOrganizationConfig_FindOrCreate(t *testing.T) { + type args struct { + organizationID string + } type wants struct { - config *chronograf.OrganizationConfig - err error + organizationConfig *chronograf.OrganizationConfig + err error } tests := []struct { - name string - wants wants + name string + args args + addFirst bool + wants wants }{ { - name: "Get config", + name: "Get non-existent default config from default org", + args: args{ + organizationID: "default", + }, + addFirst: false, wants: wants{ - config: &chronograf.OrganizationConfig{ + organizationConfig: &chronograf.OrganizationConfig{ + OrganizationID: "default", LogViewer: chronograf.LogViewerConfig{ Columns: []chronograf.LogViewerColumn{ { @@ -129,64 +139,40 @@ func TestConfig_Get(t *testing.T) { }, }, }, - } - for _, tt := range tests { - client, err := NewTestClient() - if err != nil { - t.Fatal(err) - } - defer client.Close() - - s := client.OrganizationConfigStore - got, err := s.Get(context.Background()) - if (tt.wants.err != nil) != (err != nil) { - t.Errorf("%q. ConfigStore.Get() error = %v, wantErr %v", tt.name, err, tt.wants.err) - continue - } - if diff := cmp.Diff(got, tt.wants.config); diff != "" { - t.Errorf("%q. ConfigStore.Get():\n-got/+want\ndiff %s", tt.name, diff) - } - } -} - -func TestConfig_Update(t *testing.T) { - type args struct { - config *chronograf.OrganizationConfig - } - type wants struct { - config *chronograf.OrganizationConfig - err error - } - tests := []struct { - name string - args args - wants wants - }{ { - name: "Set config", + name: "Get non-existent default config from non-default org", args: args{ - config: &chronograf.OrganizationConfig{ + organizationID: "1", + }, + addFirst: false, + wants: wants{ + organizationConfig: &chronograf.OrganizationConfig{ + OrganizationID: "1", LogViewer: chronograf.LogViewerConfig{ Columns: []chronograf.LogViewerColumn{ { Name: "time", - Position: 1, + Position: 0, Encodings: []chronograf.ColumnEncoding{ { Type: "visibility", - Value: "visible", + Value: "hidden", }, }, }, { Name: "severity", - Position: 0, + Position: 1, Encodings: []chronograf.ColumnEncoding{ { Type: "visibility", Value: "visible", }, + { + Type: "label", + Value: "icon", + }, { Type: "label", Value: "text", @@ -237,7 +223,7 @@ func TestConfig_Update(t *testing.T) { }, { Type: "displayName", - Value: "Milkshake", + Value: "Proc ID", }, }, }, @@ -269,8 +255,16 @@ func TestConfig_Update(t *testing.T) { }, }, }, + }, + { + name: "Get existing/modified config from default org", + args: args{ + organizationID: "default", + }, + addFirst: true, wants: wants{ - config: &chronograf.OrganizationConfig{ + organizationConfig: &chronograf.OrganizationConfig{ + OrganizationID: "default", LogViewer: chronograf.LogViewerConfig{ Columns: []chronograf.LogViewerColumn{ { @@ -279,7 +273,7 @@ func TestConfig_Update(t *testing.T) { Encodings: []chronograf.ColumnEncoding{ { Type: "visibility", - Value: "visible", + Value: "hidden", }, }, }, @@ -290,7 +284,11 @@ func TestConfig_Update(t *testing.T) { { Type: "visibility", - Value: "visible", + Value: "hidden", + }, + { + Type: "label", + Value: "icon", }, { Type: "label", @@ -342,7 +340,124 @@ func TestConfig_Update(t *testing.T) { }, { Type: "displayName", - Value: "Milkshake", + Value: "Proc ID", + }, + }, + }, + { + Name: "appname", + Position: 6, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "visibility", + Value: "visible", + }, + { + Type: "displayName", + Value: "Application", + }, + }, + }, + { + Name: "host", + Position: 7, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "visibility", + Value: "visible", + }, + }, + }, + }, + }, + }, + }, + }, + { + name: "Get existing/modified config from non-default org", + args: args{ + organizationID: "1", + }, + addFirst: true, + wants: wants{ + organizationConfig: &chronograf.OrganizationConfig{ + OrganizationID: "1", + LogViewer: chronograf.LogViewerConfig{ + Columns: []chronograf.LogViewerColumn{ + { + Name: "time", + Position: 1, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "visibility", + Value: "hidden", + }, + }, + }, + { + Name: "severity", + Position: 0, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "hidden", + }, + { + Type: "label", + Value: "icon", + }, + { + Type: "label", + Value: "text", + }, + }, + }, + { + Name: "timestamp", + Position: 2, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + }, + }, + { + Name: "message", + Position: 3, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + }, + }, + { + Name: "facility", + Position: 4, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + }, + }, + { + Name: "procid", + Position: 5, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + { + Type: "displayName", + Value: "Proc ID", }, }, }, @@ -384,20 +499,494 @@ func TestConfig_Update(t *testing.T) { defer client.Close() s := client.OrganizationConfigStore - err = s.Update(context.Background(), tt.args.config) - if (tt.wants.err != nil) != (err != nil) { - t.Errorf("%q. ConfigStore.Get() error = %v, wantErr %v", tt.name, err, tt.wants.err) - continue + + if tt.addFirst { + if err := s.Update(context.Background(), tt.wants.organizationConfig); err != nil { + t.Fatal(err) + } } - got, _ := s.Get(context.Background()) + got, err := s.FindOrCreate(context.Background(), tt.args.organizationID) + if (tt.wants.err != nil) != (err != nil) { - t.Errorf("%q. ConfigStore.Get() error = %v, wantErr %v", tt.name, err, tt.wants.err) + t.Errorf("%q. OrganizationConfigStore.FindOrCreate() error = %v, wantErr %v", tt.name, err, tt.wants.err) continue } - - if diff := cmp.Diff(got, tt.wants.config); diff != "" { - t.Errorf("%q. ConfigStore.Get():\n-got/+want\ndiff %s", tt.name, diff) + if diff := cmp.Diff(got, tt.wants.organizationConfig); diff != "" { + t.Errorf("%q. OrganizationConfigStore.FindOrCreate():\n-got/+want\ndiff %s", tt.name, diff) + } + } +} + +func TestOrganizationConfig_Update(t *testing.T) { + type args struct { + organizationConfig *chronograf.OrganizationConfig + organizationID string + } + type wants struct { + organizationConfig *chronograf.OrganizationConfig + err error + } + tests := []struct { + name string + args args + wants wants + }{ + { + name: "Set default org config", + args: args{ + organizationConfig: &chronograf.OrganizationConfig{ + OrganizationID: "default", + LogViewer: chronograf.LogViewerConfig{ + Columns: []chronograf.LogViewerColumn{ + { + Name: "time", + Position: 1, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "visibility", + Value: "visible", + }, + }, + }, + { + Name: "severity", + Position: 0, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + { + Type: "label", + Value: "text", + }, + }, + }, + { + Name: "timestamp", + Position: 2, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + }, + }, + { + Name: "message", + Position: 3, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + }, + }, + { + Name: "facility", + Position: 4, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + }, + }, + { + Name: "procid", + Position: 5, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + { + Type: "displayName", + Value: "Milkshake", + }, + }, + }, + { + Name: "appname", + Position: 6, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "visibility", + Value: "visible", + }, + { + Type: "displayName", + Value: "Application", + }, + }, + }, + { + Name: "host", + Position: 7, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "visibility", + Value: "visible", + }, + }, + }, + }, + }, + }, + organizationID: "default", + }, + wants: wants{ + organizationConfig: &chronograf.OrganizationConfig{ + LogViewer: chronograf.LogViewerConfig{ + Columns: []chronograf.LogViewerColumn{ + { + Name: "time", + Position: 1, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "visibility", + Value: "visible", + }, + }, + }, + { + Name: "severity", + Position: 0, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + { + Type: "label", + Value: "text", + }, + }, + }, + { + Name: "timestamp", + Position: 2, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + }, + }, + { + Name: "message", + Position: 3, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + }, + }, + { + Name: "facility", + Position: 4, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + }, + }, + { + Name: "procid", + Position: 5, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + { + Type: "displayName", + Value: "Milkshake", + }, + }, + }, + { + Name: "appname", + Position: 6, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "visibility", + Value: "visible", + }, + { + Type: "displayName", + Value: "Application", + }, + }, + }, + { + Name: "host", + Position: 7, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "visibility", + Value: "visible", + }, + }, + }, + }, + }, + OrganizationID: "default", + }, + }, + }, + { + name: "Set non-default org config", + args: args{ + organizationConfig: &chronograf.OrganizationConfig{ + OrganizationID: "1337", + LogViewer: chronograf.LogViewerConfig{ + Columns: []chronograf.LogViewerColumn{ + { + Name: "time", + Position: 1, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "visibility", + Value: "visible", + }, + }, + }, + { + Name: "severity", + Position: 0, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + { + Type: "label", + Value: "text", + }, + }, + }, + { + Name: "timestamp", + Position: 2, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + }, + }, + { + Name: "message", + Position: 3, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + }, + }, + { + Name: "facility", + Position: 4, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + }, + }, + { + Name: "procid", + Position: 5, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + { + Type: "displayName", + Value: "Milkshake", + }, + }, + }, + { + Name: "appname", + Position: 6, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "visibility", + Value: "visible", + }, + { + Type: "displayName", + Value: "Application", + }, + }, + }, + { + Name: "host", + Position: 7, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "visibility", + Value: "visible", + }, + }, + }, + }, + }, + }, + organizationID: "1337", + }, + wants: wants{ + organizationConfig: &chronograf.OrganizationConfig{ + LogViewer: chronograf.LogViewerConfig{ + Columns: []chronograf.LogViewerColumn{ + { + Name: "time", + Position: 1, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "visibility", + Value: "visible", + }, + }, + }, + { + Name: "severity", + Position: 0, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + { + Type: "label", + Value: "text", + }, + }, + }, + { + Name: "timestamp", + Position: 2, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + }, + }, + { + Name: "message", + Position: 3, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + }, + }, + { + Name: "facility", + Position: 4, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + }, + }, + { + Name: "procid", + Position: 5, + Encodings: []chronograf.ColumnEncoding{ + + { + Type: "visibility", + Value: "visible", + }, + { + Type: "displayName", + Value: "Milkshake", + }, + }, + }, + { + Name: "appname", + Position: 6, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "visibility", + Value: "visible", + }, + { + Type: "displayName", + Value: "Application", + }, + }, + }, + { + Name: "host", + Position: 7, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "visibility", + Value: "visible", + }, + }, + }, + }, + }, + OrganizationID: "1337", + }, + }, + }, + } + for _, tt := range tests { + client, err := NewTestClient() + if err != nil { + t.Fatal(err) + } + defer client.Close() + + s := client.OrganizationConfigStore + err = s.Update(context.Background(), tt.args.organizationConfig) + if (tt.wants.err != nil) != (err != nil) { + t.Errorf("%q. OrganizationConfigStore.Update() error = %v, wantErr %v", tt.name, err, tt.wants.err) + continue + } + + got, _ := s.FindOrCreate(context.Background(), tt.args.organizationID) + if (tt.wants.err != nil) != (err != nil) { + t.Errorf("%q. OrganizationConfigStore.Update() error = %v, wantErr %v", tt.name, err, tt.wants.err) + continue + } + + if diff := cmp.Diff(got, tt.wants.organizationConfig); diff != "" { + t.Errorf("%q. OrganizationConfigStore.Update():\n-got/+want\ndiff %s", tt.name, diff) } } } diff --git a/chronograf.go b/chronograf.go index 3e736fa827..f7919ef07e 100644 --- a/chronograf.go +++ b/chronograf.go @@ -9,35 +9,36 @@ import ( // General errors. const ( - ErrUpstreamTimeout = Error("request to backend timed out") - ErrSourceNotFound = Error("source not found") - ErrServerNotFound = Error("server not found") - ErrLayoutNotFound = Error("layout not found") - ErrDashboardNotFound = Error("dashboard not found") - ErrUserNotFound = Error("user not found") - ErrLayoutInvalid = Error("layout is invalid") - ErrDashboardInvalid = Error("dashboard is invalid") - ErrSourceInvalid = Error("source is invalid") - ErrServerInvalid = Error("server is invalid") - ErrAlertNotFound = Error("alert not found") - ErrAuthentication = Error("user not authenticated") - ErrUninitialized = Error("client uninitialized. Call Open() method") - ErrInvalidAxis = Error("Unexpected axis in cell. Valid axes are 'x', 'y', and 'y2'") - ErrInvalidColorType = Error("Invalid color type. Valid color types are 'min', 'max', 'threshold', 'text', and 'background'") - ErrInvalidColor = Error("Invalid color. Accepted color format is #RRGGBB") - ErrInvalidLegend = Error("Invalid legend. Both type and orientation must be set") - ErrInvalidLegendType = Error("Invalid legend type. Valid legend type is 'static'") - ErrInvalidLegendOrient = Error("Invalid orientation type. Valid orientation types are 'top', 'bottom', 'right', 'left'") - ErrUserAlreadyExists = Error("user already exists") - ErrOrganizationNotFound = Error("organization not found") - ErrMappingNotFound = Error("mapping not found") - ErrOrganizationAlreadyExists = Error("organization already exists") - ErrCannotDeleteDefaultOrganization = Error("cannot delete default organization") - ErrConfigNotFound = Error("cannot find configuration") - ErrAnnotationNotFound = Error("annotation not found") - ErrInvalidCellOptionsText = Error("invalid text wrapping option. Valid wrappings are 'truncate', 'wrap', and 'single line'") - ErrInvalidCellOptionsSort = Error("cell options sortby cannot be empty'") - ErrInvalidCellOptionsColumns = Error("cell options columns cannot be empty'") + ErrUpstreamTimeout = Error("request to backend timed out") + ErrSourceNotFound = Error("source not found") + ErrServerNotFound = Error("server not found") + ErrLayoutNotFound = Error("layout not found") + ErrDashboardNotFound = Error("dashboard not found") + ErrUserNotFound = Error("user not found") + ErrLayoutInvalid = Error("layout is invalid") + ErrDashboardInvalid = Error("dashboard is invalid") + ErrSourceInvalid = Error("source is invalid") + ErrServerInvalid = Error("server is invalid") + ErrAlertNotFound = Error("alert not found") + ErrAuthentication = Error("user not authenticated") + ErrUninitialized = Error("client uninitialized. Call Open() method") + ErrInvalidAxis = Error("Unexpected axis in cell. Valid axes are 'x', 'y', and 'y2'") + ErrInvalidColorType = Error("Invalid color type. Valid color types are 'min', 'max', 'threshold', 'text', and 'background'") + ErrInvalidColor = Error("Invalid color. Accepted color format is #RRGGBB") + ErrInvalidLegend = Error("Invalid legend. Both type and orientation must be set") + ErrInvalidLegendType = Error("Invalid legend type. Valid legend type is 'static'") + ErrInvalidLegendOrient = Error("Invalid orientation type. Valid orientation types are 'top', 'bottom', 'right', 'left'") + ErrUserAlreadyExists = Error("user already exists") + ErrOrganizationNotFound = Error("organization not found") + ErrMappingNotFound = Error("mapping not found") + ErrOrganizationAlreadyExists = Error("organization already exists") + ErrCannotDeleteDefaultOrganization = Error("cannot delete default organization") + ErrConfigNotFound = Error("cannot find configuration") + ErrAnnotationNotFound = Error("annotation not found") + ErrInvalidCellOptionsText = Error("invalid text wrapping option. Valid wrappings are 'truncate', 'wrap', and 'single line'") + ErrInvalidCellOptionsSort = Error("cell options sortby cannot be empty'") + ErrInvalidCellOptionsColumns = Error("cell options columns cannot be empty'") + ErrOrganizationConfigFindOrCreateFailed = Error("failed to find or create organization config") ) // Error is a domain error encountered while processing chronograf requests @@ -760,7 +761,8 @@ type ConfigStore interface { // OrganizationConfig is the organization config for parameters that can // be set via API, with different sections, such as LogViewer type OrganizationConfig struct { - LogViewer LogViewerConfig `json:"logViewer"` + OrganizationID string `json:"organization"` + LogViewer LogViewerConfig `json:"logViewer"` } // LogViewerConfig is the configuration settings for the Log Viewer UI @@ -784,12 +786,10 @@ type ColumnEncoding struct { // OrganizationConfigStore is the storage and retrieval of organization Configs type OrganizationConfigStore interface { - // Initialize creates the initial configuration - Initialize(context.Context) error - // Get retrieves the whole Config from the OrganizationConfigStore - Get(context.Context) (*Config, error) - // Update updates the whole Config in the OrganizationConfigStore - Update(context.Context, *Config) error + // FindOrCreate gets an existing OrganizationConfig and creates one if none exists + FindOrCreate(ctx context.Context, orgID string) (*OrganizationConfig, error) + // Update updates the whole organization config in the OrganizationConfigStore + Update(context.Context, *OrganizationConfig) error } // BuildInfo is sent to the usage client to track versions and commits diff --git a/mocks/org_config.go b/mocks/org_config.go new file mode 100644 index 0000000000..6675f9a5b5 --- /dev/null +++ b/mocks/org_config.go @@ -0,0 +1,24 @@ +package mocks + +import ( + "context" + + "github.com/influxdata/chronograf" +) + +var _ chronograf.OrganizationConfigStore = &OrganizationConfigStore{} + +type OrganizationConfigStore struct { + //InitializeF func(ctx context.Context) error + //GetF func(ctx context.Context, id chronograf.OrganizationID) (*chronograf.OrganizationConfig, error) + FindOrCreateF func(ctx context.Context, id string) (*chronograf.OrganizationConfig, error) + UpdateF func(ctx context.Context, target *chronograf.OrganizationConfig) error +} + +func (oc *OrganizationConfigStore) FindOrCreate(ctx context.Context, id string) (*chronograf.OrganizationConfig, error) { + return oc.FindOrCreateF(ctx, id) +} + +func (oc *OrganizationConfigStore) Update(ctx context.Context, target *chronograf.OrganizationConfig) error { + return oc.UpdateF(ctx, target) +} diff --git a/mocks/store.go b/mocks/store.go index 8cb27b11b0..eba7809d78 100644 --- a/mocks/store.go +++ b/mocks/store.go @@ -8,14 +8,15 @@ import ( // Store is a server.DataStore type Store struct { - SourcesStore chronograf.SourcesStore - MappingsStore chronograf.MappingsStore - ServersStore chronograf.ServersStore - LayoutsStore chronograf.LayoutsStore - UsersStore chronograf.UsersStore - DashboardsStore chronograf.DashboardsStore - OrganizationsStore chronograf.OrganizationsStore - ConfigStore chronograf.ConfigStore + SourcesStore chronograf.SourcesStore + MappingsStore chronograf.MappingsStore + ServersStore chronograf.ServersStore + LayoutsStore chronograf.LayoutsStore + UsersStore chronograf.UsersStore + DashboardsStore chronograf.DashboardsStore + OrganizationsStore chronograf.OrganizationsStore + ConfigStore chronograf.ConfigStore + OrganizationConfigStore chronograf.OrganizationConfigStore } func (s *Store) Sources(ctx context.Context) chronograf.SourcesStore { @@ -48,3 +49,7 @@ func (s *Store) Dashboards(ctx context.Context) chronograf.DashboardsStore { func (s *Store) Config(ctx context.Context) chronograf.ConfigStore { return s.ConfigStore } + +func (s *Store) OrganizationConfig(ctx context.Context) chronograf.OrganizationConfigStore { + return s.OrganizationConfigStore +} diff --git a/noop/org_config.go b/noop/org_config.go new file mode 100644 index 0000000000..8906f4de64 --- /dev/null +++ b/noop/org_config.go @@ -0,0 +1,21 @@ +package noop + +import ( + "context" + "fmt" + + "github.com/influxdata/chronograf" +) + +// ensure OrganizationConfigStore implements chronograf.OrganizationConfigStore +var _ chronograf.OrganizationConfigStore = &OrganizationConfigStore{} + +type OrganizationConfigStore struct{} + +func (s *OrganizationConfigStore) FindOrCreate(context.Context, string) (*chronograf.OrganizationConfig, error) { + return nil, chronograf.ErrOrganizationConfigFindOrCreateFailed +} + +func (s *OrganizationConfigStore) Update(context.Context, *chronograf.OrganizationConfig) error { + return fmt.Errorf("cannot update conifg") +} diff --git a/organizations/org_config.go b/organizations/org_config.go new file mode 100644 index 0000000000..15f6ad2d0d --- /dev/null +++ b/organizations/org_config.go @@ -0,0 +1,56 @@ +package organizations + +import ( + "context" + + "github.com/influxdata/chronograf" +) + +// ensure that OrganizationConfig implements chronograf.OrganizationConfigStore +var _ chronograf.OrganizationConfigStore = &OrganizationConfigStore{} + +// OrganizationConfigStore facade on a OrganizationConfig that filters OrganizationConfigs by organization. +type OrganizationConfigStore struct { + store chronograf.OrganizationConfigStore + organization string +} + +// NewOrganizationConfigStore creates a new OrganizationConfigStore from an existing +// chronograf.OrganizationConfigStore and an organization string +func NewOrganizationConfigStore(s chronograf.OrganizationConfigStore, orgID string) *OrganizationConfigStore { + return &OrganizationConfigStore{ + store: s, + organization: orgID, + } +} + +// FindOrCreate gets an organization's config or creates one if none exists +func (s *OrganizationConfigStore) FindOrCreate(ctx context.Context, orgID string) (*chronograf.OrganizationConfig, error) { + var err = validOrganization(ctx) + if err != nil { + return nil, err + } + + oc, err := s.store.FindOrCreate(ctx, orgID) + if err != nil { + return nil, err + } + + return oc, nil + +} + +// Update the OrganizationConfig in OrganizationConfigStore. +func (s *OrganizationConfigStore) Update(ctx context.Context, oc *chronograf.OrganizationConfig) error { + err := validOrganization(ctx) + if err != nil { + return err + } + + _, err = s.store.FindOrCreate(ctx, oc.OrganizationID) + if err != nil { + return err + } + + return s.store.Update(ctx, oc) +} diff --git a/server/auth.go b/server/auth.go index be1a08abf0..3a698d09f8 100644 --- a/server/auth.go +++ b/server/auth.go @@ -95,13 +95,8 @@ func AuthorizedUser( next http.HandlerFunc, ) http.HandlerFunc { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if !useAuth { - ctx := r.Context() - // If there is no auth, then give the user raw access to the DataStore - r = r.WithContext(serverContext(ctx)) - next(w, r) - return - } + ctx := r.Context() + serverCtx := serverContext(ctx) log := logger. WithField("component", "role_auth"). @@ -109,8 +104,24 @@ func AuthorizedUser( WithField("method", r.Method). WithField("url", r.URL) - ctx := r.Context() - serverCtx := serverContext(ctx) + defaultOrg, err := store.Organizations(serverCtx).DefaultOrganization(serverCtx) + if err != nil { + log.Error(fmt.Sprintf("Failed to retrieve the default organization: %v", err)) + Error(w, http.StatusForbidden, "User is not authorized", logger) + return + } + + if !useAuth { + // If there is no auth, then set the organization id to be the default org id on context + // so that calls like hasOrganizationContext as used in Organization Config service + // method OrganizationConfig can successfully get the organization id + ctx = context.WithValue(ctx, organizations.ContextKey, defaultOrg.ID) + + // And if there is no auth, then give the user raw access to the DataStore + r = r.WithContext(serverContext(ctx)) + next(w, r) + return + } p, err := getValidPrincipal(ctx) if err != nil { @@ -127,12 +138,6 @@ func AuthorizedUser( // This is as if the user was logged into the default organization if p.Organization == "" { - defaultOrg, err := store.Organizations(serverCtx).DefaultOrganization(serverCtx) - if err != nil { - log.Error(fmt.Sprintf("Failed to retrieve the default organization: %v", err)) - Error(w, http.StatusForbidden, "User is not authorized", logger) - return - } p.Organization = defaultOrg.ID } diff --git a/server/auth_test.go b/server/auth_test.go index ff1afdf1ff..2ec8796bc1 100644 --- a/server/auth_test.go +++ b/server/auth_test.go @@ -63,7 +63,6 @@ func TestAuthorizedToken(t *testing.T) { } } } - func TestAuthorizedUser(t *testing.T) { type fields struct { UsersStore chronograf.UsersStore @@ -102,7 +101,7 @@ func TestAuthorizedUser(t *testing.T) { args: args{ useAuth: false, }, - hasOrganizationContext: false, + hasOrganizationContext: true, hasSuperAdminContext: false, hasRoleContext: false, hasServerContext: true, @@ -1047,6 +1046,11 @@ func TestAuthorizedUser(t *testing.T) { Name: "The ShillBillThrilliettas", }, nil }, + DefaultOrganizationF: func(ctx context.Context) (*chronograf.Organization, error) { + return &chronograf.Organization{ + ID: "0", + }, nil + }, }, Logger: clog.New(clog.DebugLevel), }, diff --git a/server/org_config.go b/server/org_config.go index 01282ac34d..d0c570fba7 100644 --- a/server/org_config.go +++ b/server/org_config.go @@ -22,17 +22,17 @@ func newOrganizationConfigResponse(config chronograf.OrganizationConfig) *organi } } -type logViewerOrganizationConfigResponse struct { +type logViewerConfigResponse struct { Links selfLinks `json:"links"` - chronograf.LogViewerOrganizationConfig + chronograf.LogViewerConfig } -func newAuthConfigResponse(config chronograf.OrganizationConfig) *logViewerOrganizationConfigResponse { - return &logViewerOrganizationConfigResponse{ +func newLogViewerConfigResponse(config chronograf.OrganizationConfig) *logViewerConfigResponse { + return &logViewerConfigResponse{ Links: selfLinks{ Self: "/chronograf/v1/org_config/logviewer", }, - LogViewerOrganizationConfig: config.LogViewer, + LogViewerConfig: config.LogViewer, } } @@ -40,14 +40,20 @@ func newAuthConfigResponse(config chronograf.OrganizationConfig) *logViewerOrgan func (s *Service) OrganizationConfig(w http.ResponseWriter, r *http.Request) { ctx := r.Context() - config, err := s.Store.OrganizationConfig(ctx).Get(ctx) + orgID, ok := hasOrganizationContext(ctx) + if !ok { + Error(w, http.StatusBadRequest, "Organization not found on context", s.Logger) + return + } + + config, err := s.Store.OrganizationConfig(ctx).FindOrCreate(ctx, orgID) if err != nil { Error(w, http.StatusBadRequest, err.Error(), s.Logger) return } if config == nil { - Error(w, http.StatusBadRequest, "Configuration object was nil", s.Logger) + Error(w, http.StatusBadRequest, "Organization configuration object was nil", s.Logger) return } res := newOrganizationConfigResponse(*config) @@ -59,14 +65,20 @@ func (s *Service) OrganizationConfig(w http.ResponseWriter, r *http.Request) { func (s *Service) LogViewerOrganizationConfig(w http.ResponseWriter, r *http.Request) { ctx := r.Context() - config, err := s.Store.OrganizationConfig(ctx).Get(ctx) + orgID, ok := hasOrganizationContext(ctx) + if !ok { + Error(w, http.StatusBadRequest, "Organization not found on context", s.Logger) + return + } + + config, err := s.Store.OrganizationConfig(ctx).FindOrCreate(ctx, orgID) if err != nil { Error(w, http.StatusBadRequest, err.Error(), s.Logger) return } if config == nil { - Error(w, http.StatusBadRequest, "Configuration object was nil", s.Logger) + Error(w, http.StatusBadRequest, "Organization configuration object was nil", s.Logger) return } @@ -79,6 +91,12 @@ func (s *Service) LogViewerOrganizationConfig(w http.ResponseWriter, r *http.Req func (s *Service) ReplaceLogViewerOrganizationConfig(w http.ResponseWriter, r *http.Request) { ctx := r.Context() + orgID, ok := hasOrganizationContext(ctx) + if !ok { + Error(w, http.StatusBadRequest, "Organization not found on context", s.Logger) + return + } + var logViewerConfig chronograf.LogViewerConfig if err := json.NewDecoder(r.Body).Decode(&logViewerConfig); err != nil { invalidJSON(w, s.Logger) @@ -89,13 +107,13 @@ func (s *Service) ReplaceLogViewerOrganizationConfig(w http.ResponseWriter, r *h return } - config, err := s.Store.OrganizationConfig(ctx).Get(ctx) + config, err := s.Store.OrganizationConfig(ctx).FindOrCreate(ctx, orgID) if err != nil { Error(w, http.StatusBadRequest, err.Error(), s.Logger) return } if config == nil { - Error(w, http.StatusBadRequest, "Configuration object was nil", s.Logger) + Error(w, http.StatusBadRequest, "Organization configuration object was nil", s.Logger) return } config.LogViewer = logViewerConfig diff --git a/server/org_config_test.go b/server/org_config_test.go index 6cbf871d67..fd36ed6d66 100644 --- a/server/org_config_test.go +++ b/server/org_config_test.go @@ -2,6 +2,7 @@ package server import ( "bytes" + "context" "encoding/json" "io/ioutil" "net/http/httptest" @@ -10,11 +11,15 @@ import ( "github.com/influxdata/chronograf" "github.com/influxdata/chronograf/log" "github.com/influxdata/chronograf/mocks" + "github.com/influxdata/chronograf/organizations" ) func TestOrganizationConfig(t *testing.T) { + type args struct { + organizationID string + } type fields struct { - OrganizationConfigStore chronograf.OrganizationConfigStore + organizationConfigStore chronograf.OrganizationConfigStore } type wants struct { statusCode int @@ -24,126 +29,138 @@ func TestOrganizationConfig(t *testing.T) { tests := []struct { name string + args args fields fields wants wants }{ { - name: "Get organization configuration settings", + name: "Get organization configuration", + args: args{ + organizationID: "default", + }, fields: fields{ - OrganizationConfigStore: &mocks.OrganizationConfigStore{ - OrganizationConfig: &chronograf.OrganizationConfig{ - LogViewer: chronograf.LogViewer{ - Columns: []chronograf.LogViewerColumn{ - { - Name: "time", - Position: 0, - Encodings: []chronograf.ColumnEncoding{ + organizationConfigStore: &mocks.OrganizationConfigStore{ + FindOrCreateF: func(ctx context.Context, orgID string) (*chronograf.OrganizationConfig, error) { + switch orgID { + case "default": + return &chronograf.OrganizationConfig{ + OrganizationID: "default", + LogViewer: chronograf.LogViewerConfig{ + Columns: []chronograf.LogViewerColumn{ { - Type: "visibility", - Value: "hidden", + Name: "time", + Position: 0, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "visibility", + Value: "hidden", + }, + }, }, - }, - }, - { - Name: "severity", - Position: 1, - Encodings: []chronograf.ColumnEncoding{ + { + Name: "severity", + Position: 1, + Encodings: []chronograf.ColumnEncoding{ - { - Type: "visibility", - Value: "visible", + { + Type: "visibility", + Value: "visible", + }, + { + Type: "label", + Value: "icon", + }, + { + Type: "label", + Value: "text", + }, + }, }, { - Type: "label", - Value: "icon", - }, - { - Type: "label", - Value: "text", - }, - }, - }, - { - Name: "timestamp", - Position: 2, - Encodings: []chronograf.ColumnEncoding{ + Name: "timestamp", + Position: 2, + Encodings: []chronograf.ColumnEncoding{ - { - Type: "visibility", - Value: "visible", + { + Type: "visibility", + Value: "visible", + }, + }, }, - }, - }, - { - Name: "message", - Position: 3, - Encodings: []chronograf.ColumnEncoding{ + { + Name: "message", + Position: 3, + Encodings: []chronograf.ColumnEncoding{ - { - Type: "visibility", - Value: "visible", + { + Type: "visibility", + Value: "visible", + }, + }, }, - }, - }, - { - Name: "facility", - Position: 4, - Encodings: []chronograf.ColumnEncoding{ + { + Name: "facility", + Position: 4, + Encodings: []chronograf.ColumnEncoding{ - { - Type: "visibility", - Value: "visible", + { + Type: "visibility", + Value: "visible", + }, + }, }, - }, - }, - { - Name: "procid", - Position: 5, - Encodings: []chronograf.ColumnEncoding{ + { + Name: "procid", + Position: 5, + Encodings: []chronograf.ColumnEncoding{ - { - Type: "visibility", - Value: "visible", + { + Type: "visibility", + Value: "visible", + }, + { + Type: "displayName", + Value: "Proc ID", + }, + }, }, { - Type: "displayName", - Value: "Proc ID", + Name: "appname", + Position: 6, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "visibility", + Value: "visible", + }, + { + Type: "displayName", + Value: "Application", + }, + }, + }, + { + Name: "host", + Position: 7, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "visibility", + Value: "visible", + }, + }, }, }, }, - { - Name: "appname", - Position: 6, - Encodings: []chronograf.ColumnEncoding{ - { - Type: "visibility", - Value: "visible", - }, - { - Type: "displayName", - Value: "Application", - }, - }, - }, - { - Name: "host", - Position: 7, - Encodings: []chronograf.ColumnEncoding{ - { - Type: "visibility", - Value: "visible", - }, - }, - }, - }, - }, + }, nil + default: + return nil, chronograf.ErrOrganizationConfigFindOrCreateFailed + } }, }, }, wants: wants{ statusCode: 200, contentType: "application/json", - body: `{"links":{"self":"/chronograf/v1/config"},"auth":{"superAdminNewUsers":false}}`, + body: `{"links":{"self":"/chronograf/v1/org_config"},"organization":"default","logViewer":{"columns":[{"name":"time","position":0,"encodings":[{"type":"visibility","value":"hidden"}]},{"name":"severity","position":1,"encodings":[{"type":"visibility","value":"visible"},{"type":"label","value":"icon"},{"type":"label","value":"text"}]},{"name":"timestamp","position":2,"encodings":[{"type":"visibility","value":"visible"}]},{"name":"message","position":3,"encodings":[{"type":"visibility","value":"visible"}]},{"name":"facility","position":4,"encodings":[{"type":"visibility","value":"visible"}]},{"name":"procid","position":5,"encodings":[{"type":"visibility","value":"visible"},{"type":"displayName","value":"Proc ID"}]},{"name":"appname","position":6,"encodings":[{"type":"visibility","value":"visible"},{"type":"displayName","value":"Application"}]},{"name":"host","position":7,"encodings":[{"type":"visibility","value":"visible"}]}]}}`, }, }, } @@ -152,36 +169,41 @@ func TestOrganizationConfig(t *testing.T) { t.Run(tt.name, func(t *testing.T) { s := &Service{ Store: &mocks.Store{ - OrganizationConfigStore: tt.fields.OrganizationConfigStore, + OrganizationConfigStore: tt.fields.organizationConfigStore, }, Logger: log.New(log.DebugLevel), } w := httptest.NewRecorder() r := httptest.NewRequest("GET", "http://any.url", nil) + ctx := context.WithValue(r.Context(), organizations.ContextKey, tt.args.organizationID) + r = r.WithContext(ctx) - s.Config(w, r) + s.OrganizationConfig(w, r) resp := w.Result() content := resp.Header.Get("Content-Type") body, _ := ioutil.ReadAll(resp.Body) if resp.StatusCode != tt.wants.statusCode { - t.Errorf("%q. Config() = %v, want %v", tt.name, resp.StatusCode, tt.wants.statusCode) + t.Errorf("%q. OrganizationConfig() = %v, want %v", tt.name, resp.StatusCode, tt.wants.statusCode) } if tt.wants.contentType != "" && content != tt.wants.contentType { - t.Errorf("%q. Config() = %v, want %v", tt.name, content, tt.wants.contentType) + t.Errorf("%q. OrganizationConfig() = %v, want %v", tt.name, content, tt.wants.contentType) } if eq, _ := jsonEqual(string(body), tt.wants.body); tt.wants.body != "" && !eq { - t.Errorf("%q. Config() = \n***%v***\n,\nwant\n***%v***", tt.name, string(body), tt.wants.body) + t.Errorf("%q. OrganizationConfig() = \n***%v***\n,\nwant\n***%v***", tt.name, string(body), tt.wants.body) } }) } } func TestLogViewerOrganizationConfig(t *testing.T) { + type args struct { + organizationID string + } type fields struct { - OrganizationConfigStore chronograf.OrganizationConfigStore + organizationConfigStore chronograf.OrganizationConfigStore } type wants struct { statusCode int @@ -191,45 +213,56 @@ func TestLogViewerOrganizationConfig(t *testing.T) { tests := []struct { name string + args args fields fields wants wants }{ { name: "Get log viewer configuration", + args: args{ + organizationID: "default", + }, fields: fields{ - OrganizationConfigStore: &mocks.OrganizationConfigStore{ - OrganizationConfig: &chronograf.OrganizationConfig{ - LogViewer: chronograf.LogViewerConfig{ - Columns: []chronograf.LogViewerColumn{ - { - Name: "severity", - Position: 0, - Encodings: []chronograf.ColumnEncoding{ + organizationConfigStore: &mocks.OrganizationConfigStore{ + FindOrCreateF: func(ctx context.Context, orgID string) (*chronograf.OrganizationConfig, error) { + switch orgID { + case "default": + return &chronograf.OrganizationConfig{ + LogViewer: chronograf.LogViewerConfig{ + Columns: []chronograf.LogViewerColumn{ { - Type: "color", - Value: "emergency", - Name: "ruby", - }, - { - Type: "color", - Value: "info", - Name: "rainforest", - }, - { - Type: "displayName", - Value: "Log Severity", + Name: "severity", + Position: 0, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "color", + Value: "emergency", + Name: "ruby", + }, + { + Type: "color", + Value: "info", + Name: "rainforest", + }, + { + Type: "displayName", + Value: "Log Severity", + }, + }, }, }, }, - }, - }, + }, nil + default: + return nil, chronograf.ErrOrganizationConfigFindOrCreateFailed + } }, }, }, wants: wants{ statusCode: 200, contentType: "application/json", - body: `{"links":{"self":"/chronograf/v1/config/logviewer"},"columns":[{"name":"severity","position":0,"encodings":[{"type":"color","value":"emergency","name":"ruby"},{"type":"color","value":"info","name":"rainforest"},{"type":"displayName","value":"Log Severity"}]}]}`, + body: `{"links":{"self":"/chronograf/v1/org_config/logviewer"},"columns":[{"name":"severity","position":0,"encodings":[{"type":"color","value":"emergency","name":"ruby"},{"type":"color","value":"info","name":"rainforest"},{"type":"displayName","value":"Log Severity"}]}]}`, }, }, } @@ -238,13 +271,15 @@ func TestLogViewerOrganizationConfig(t *testing.T) { t.Run(tt.name, func(t *testing.T) { s := &Service{ Store: &mocks.Store{ - ConfigStore: tt.fields.ConfigStore, + OrganizationConfigStore: tt.fields.organizationConfigStore, }, Logger: log.New(log.DebugLevel), } w := httptest.NewRecorder() r := httptest.NewRequest("GET", "http://any.url", nil) + ctx := context.WithValue(r.Context(), organizations.ContextKey, tt.args.organizationID) + r = r.WithContext(ctx) s.LogViewerOrganizationConfig(w, r) @@ -267,10 +302,11 @@ func TestLogViewerOrganizationConfig(t *testing.T) { func TestReplaceLogViewerOrganizationConfig(t *testing.T) { type fields struct { - ConfigStore chronograf.OrganizationConfigStore + organizationConfigStore chronograf.OrganizationConfigStore } type args struct { - payload interface{} // expects JSON serializable struct + payload interface{} // expects JSON serializable struct + organizationID string } type wants struct { statusCode int @@ -287,31 +323,41 @@ func TestReplaceLogViewerOrganizationConfig(t *testing.T) { { name: "Set log viewer configuration", fields: fields{ - ConfigStore: &mocks.OrganizationConfigStore{ - OrganizationConfig: &chronograf.OrganizationConfig{ - LogViewer: chronograf.LogViewerConfig{ - Columns: []chronograf.LogViewerColumn{ - { - Name: "severity", - Position: 0, - Encodings: []chronograf.ColumnEncoding{ + organizationConfigStore: &mocks.OrganizationConfigStore{ + FindOrCreateF: func(ctx context.Context, orgID string) (*chronograf.OrganizationConfig, error) { + switch orgID { + case "1337": + return &chronograf.OrganizationConfig{ + LogViewer: chronograf.LogViewerConfig{ + Columns: []chronograf.LogViewerColumn{ { - Type: "color", - Value: "info", - Name: "rainforest", - }, - { - Type: "visibility", - Value: "visible", - }, - { - Type: "label", - Value: "icon", + Name: "severity", + Position: 0, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "color", + Value: "info", + Name: "rainforest", + }, + { + Type: "visibility", + Value: "visible", + }, + { + Type: "label", + Value: "icon", + }, + }, }, }, }, - }, - }, + }, nil + default: + return nil, chronograf.ErrOrganizationConfigFindOrCreateFailed + } + }, + UpdateF: func(ctx context.Context, target *chronograf.OrganizationConfig) error { + return nil }, }, }, @@ -358,41 +404,52 @@ func TestReplaceLogViewerOrganizationConfig(t *testing.T) { }, }, }, + organizationID: "1337", }, wants: wants{ statusCode: 200, contentType: "application/json", - body: `{"links":{"self":"/chronograf/v1/config/logviewer"},"columns":[{"name":"severity","position":1,"encodings":[{"type":"color","value":"info","name":"pineapple"},{"type":"color","value":"emergency","name":"ruby"},{"type":"visibility","value":"visible"},{"type":"label","value":"icon"}]},{"name":"messages","position":0,"encodings":[{"type":"displayName","value":"Log Messages"},{"type":"visibility","value":"visible"}]}]}`, + body: `{"links":{"self":"/chronograf/v1/org_config/logviewer"},"columns":[{"name":"severity","position":1,"encodings":[{"type":"color","value":"info","name":"pineapple"},{"type":"color","value":"emergency","name":"ruby"},{"type":"visibility","value":"visible"},{"type":"label","value":"icon"}]},{"name":"messages","position":0,"encodings":[{"type":"displayName","value":"Log Messages"},{"type":"visibility","value":"visible"}]}]}`, }, }, { name: "Set invalid log viewer configuration – empty", fields: fields{ - ConfigStore: &mocks.OrganizationConfigStore{ - OrganizationConfig: &chronograf.OrganizationConfig{ - LogViewer: chronograf.LogViewerConfig{ - Columns: []chronograf.LogViewerColumn{ - { - Name: "severity", - Position: 0, - Encodings: []chronograf.ColumnEncoding{ + organizationConfigStore: &mocks.OrganizationConfigStore{ + FindOrCreateF: func(ctx context.Context, orgID string) (*chronograf.OrganizationConfig, error) { + switch orgID { + case "1337": + return &chronograf.OrganizationConfig{ + LogViewer: chronograf.LogViewerConfig{ + Columns: []chronograf.LogViewerColumn{ { - Type: "color", - Value: "info", - Name: "rainforest", - }, - { - Type: "label", - Value: "icon", - }, - { - Type: "visibility", - Value: "visible", + Name: "severity", + Position: 0, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "color", + Value: "info", + Name: "rainforest", + }, + { + Type: "label", + Value: "icon", + }, + { + Type: "visibility", + Value: "visible", + }, + }, }, }, }, - }, - }, + }, nil + default: + return nil, chronograf.ErrOrganizationConfigFindOrCreateFailed + } + }, + UpdateF: func(ctx context.Context, target *chronograf.OrganizationConfig) error { + return nil }, }, }, @@ -400,6 +457,7 @@ func TestReplaceLogViewerOrganizationConfig(t *testing.T) { payload: chronograf.LogViewerConfig{ Columns: []chronograf.LogViewerColumn{}, }, + organizationID: "1337", }, wants: wants{ statusCode: 400, @@ -410,22 +468,32 @@ func TestReplaceLogViewerOrganizationConfig(t *testing.T) { { name: "Set invalid log viewer configuration - duplicate column name", fields: fields{ - ConfigStore: &mocks.OrganizationConfigStore{ - OrganizationConfig: &chronograf.OrganizationConfig{ - LogViewer: chronograf.LogViewerConfig{ - Columns: []chronograf.LogViewerColumn{ - { - Name: "procid", - Position: 0, - Encodings: []chronograf.ColumnEncoding{ + organizationConfigStore: &mocks.OrganizationConfigStore{ + FindOrCreateF: func(ctx context.Context, orgID string) (*chronograf.OrganizationConfig, error) { + switch orgID { + case "1337": + return &chronograf.OrganizationConfig{ + LogViewer: chronograf.LogViewerConfig{ + Columns: []chronograf.LogViewerColumn{ { - Type: "visibility", - Value: "hidden", + Name: "procid", + Position: 0, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "visibility", + Value: "hidden", + }, + }, }, }, }, - }, - }, + }, nil + default: + return nil, chronograf.ErrOrganizationConfigFindOrCreateFailed + } + }, + UpdateF: func(ctx context.Context, target *chronograf.OrganizationConfig) error { + return nil }, }, }, @@ -454,6 +522,7 @@ func TestReplaceLogViewerOrganizationConfig(t *testing.T) { }, }, }, + organizationID: "1337", }, wants: wants{ statusCode: 400, @@ -464,22 +533,32 @@ func TestReplaceLogViewerOrganizationConfig(t *testing.T) { { name: "Set invalid log viewer configuration - multiple columns with same position value", fields: fields{ - ConfigStore: &mocks.OrganizationConfigStore{ - OrganizationConfig: &chronograf.OrganizationConfig{ - LogViewer: chronograf.LogViewerConfig{ - Columns: []chronograf.LogViewerColumn{ - { - Name: "procid", - Position: 0, - Encodings: []chronograf.ColumnEncoding{ + organizationConfigStore: &mocks.OrganizationConfigStore{ + FindOrCreateF: func(ctx context.Context, orgID string) (*chronograf.OrganizationConfig, error) { + switch orgID { + case "1337": + return &chronograf.OrganizationConfig{ + LogViewer: chronograf.LogViewerConfig{ + Columns: []chronograf.LogViewerColumn{ { - Type: "visibility", - Value: "hidden", + Name: "procid", + Position: 0, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "visibility", + Value: "hidden", + }, + }, }, }, }, - }, - }, + }, nil + default: + return nil, chronograf.ErrOrganizationConfigFindOrCreateFailed + } + }, + UpdateF: func(ctx context.Context, target *chronograf.OrganizationConfig) error { + return nil }, }, }, @@ -508,6 +587,7 @@ func TestReplaceLogViewerOrganizationConfig(t *testing.T) { }, }, }, + organizationID: "1337", }, wants: wants{ statusCode: 400, @@ -518,27 +598,37 @@ func TestReplaceLogViewerOrganizationConfig(t *testing.T) { { name: "Set invalid log viewer configuration – no visibility", fields: fields{ - ConfigStore: &mocks.OrganizationConfigStore{ - OrganizationConfig: &chronograf.OrganizationConfig{ - LogViewer: chronograf.LogViewerConfig{ - Columns: []chronograf.LogViewerColumn{ - { - Name: "severity", - Position: 0, - Encodings: []chronograf.ColumnEncoding{ + organizationConfigStore: &mocks.OrganizationConfigStore{ + FindOrCreateF: func(ctx context.Context, orgID string) (*chronograf.OrganizationConfig, error) { + switch orgID { + case "1337": + return &chronograf.OrganizationConfig{ + LogViewer: chronograf.LogViewerConfig{ + Columns: []chronograf.LogViewerColumn{ { - Type: "color", - Value: "info", - Name: "rainforest", - }, - { - Type: "label", - Value: "icon", + Name: "severity", + Position: 0, + Encodings: []chronograf.ColumnEncoding{ + { + Type: "color", + Value: "info", + Name: "rainforest", + }, + { + Type: "label", + Value: "icon", + }, + }, }, }, }, - }, - }, + }, nil + default: + return nil, chronograf.ErrOrganizationConfigFindOrCreateFailed + } + }, + UpdateF: func(ctx context.Context, target *chronograf.OrganizationConfig) error { + return nil }, }, }, @@ -567,6 +657,7 @@ func TestReplaceLogViewerOrganizationConfig(t *testing.T) { }, }, }, + organizationID: "1337", }, wants: wants{ statusCode: 400, @@ -580,13 +671,15 @@ func TestReplaceLogViewerOrganizationConfig(t *testing.T) { t.Run(tt.name, func(t *testing.T) { s := &Service{ Store: &mocks.Store{ - OrganizationConfigStore: tt.fields.OrganizationConfigStore, + OrganizationConfigStore: tt.fields.organizationConfigStore, }, Logger: log.New(log.DebugLevel), } w := httptest.NewRecorder() r := httptest.NewRequest("GET", "http://any.url", nil) + ctx := context.WithValue(r.Context(), organizations.ContextKey, tt.args.organizationID) + r = r.WithContext(ctx) buf, _ := json.Marshal(tt.args.payload) r.Body = ioutil.NopCloser(bytes.NewReader(buf)) diff --git a/server/server.go b/server/server.go index 0c1db806f0..a80297f3fd 100644 --- a/server/server.go +++ b/server/server.go @@ -486,14 +486,15 @@ func openService(ctx context.Context, buildInfo chronograf.BuildInfo, boltPath s return Service{ TimeSeriesClient: &InfluxClient{}, Store: &Store{ - LayoutsStore: layouts, - DashboardsStore: dashboards, - SourcesStore: sources, - ServersStore: kapacitors, - OrganizationsStore: organizations, - UsersStore: db.UsersStore, - ConfigStore: db.ConfigStore, - MappingsStore: db.MappingsStore, + LayoutsStore: layouts, + DashboardsStore: dashboards, + SourcesStore: sources, + ServersStore: kapacitors, + OrganizationsStore: organizations, + UsersStore: db.UsersStore, + ConfigStore: db.ConfigStore, + MappingsStore: db.MappingsStore, + OrganizationConfigStore: db.OrganizationConfigStore, }, Logger: logger, UseAuth: useAuth, diff --git a/server/stores.go b/server/stores.go index 09fe6b2468..fe1fec355e 100644 --- a/server/stores.go +++ b/server/stores.go @@ -91,6 +91,7 @@ type DataStore interface { Mappings(ctx context.Context) chronograf.MappingsStore Dashboards(ctx context.Context) chronograf.DashboardsStore Config(ctx context.Context) chronograf.ConfigStore + OrganizationConfig(ctx context.Context) chronograf.OrganizationConfigStore } // ensure that Store implements a DataStore @@ -98,18 +99,19 @@ var _ DataStore = &Store{} // Store implements the DataStore interface type Store struct { - SourcesStore chronograf.SourcesStore - ServersStore chronograf.ServersStore - LayoutsStore chronograf.LayoutsStore - UsersStore chronograf.UsersStore - DashboardsStore chronograf.DashboardsStore - MappingsStore chronograf.MappingsStore - OrganizationsStore chronograf.OrganizationsStore - ConfigStore chronograf.ConfigStore + SourcesStore chronograf.SourcesStore + ServersStore chronograf.ServersStore + LayoutsStore chronograf.LayoutsStore + UsersStore chronograf.UsersStore + DashboardsStore chronograf.DashboardsStore + MappingsStore chronograf.MappingsStore + OrganizationsStore chronograf.OrganizationsStore + ConfigStore chronograf.ConfigStore + OrganizationConfigStore chronograf.OrganizationConfigStore } // Sources returns a noop.SourcesStore if the context has no organization specified -// and a organization.SourcesStore otherwise. +// and an organization.SourcesStore otherwise. func (s *Store) Sources(ctx context.Context) chronograf.SourcesStore { if isServer := hasServerContext(ctx); isServer { return s.SourcesStore @@ -122,7 +124,7 @@ func (s *Store) Sources(ctx context.Context) chronograf.SourcesStore { } // Servers returns a noop.ServersStore if the context has no organization specified -// and a organization.ServersStore otherwise. +// and an organization.ServersStore otherwise. func (s *Store) Servers(ctx context.Context) chronograf.ServersStore { if isServer := hasServerContext(ctx); isServer { return s.ServersStore @@ -157,7 +159,7 @@ func (s *Store) Users(ctx context.Context) chronograf.UsersStore { } // Dashboards returns a noop.DashboardsStore if the context has no organization specified -// and a organization.DashboardsStore otherwise. +// and an organization.DashboardsStore otherwise. func (s *Store) Dashboards(ctx context.Context) chronograf.DashboardsStore { if isServer := hasServerContext(ctx); isServer { return s.DashboardsStore @@ -169,17 +171,17 @@ func (s *Store) Dashboards(ctx context.Context) chronograf.DashboardsStore { return &noop.DashboardsStore{} } -// Settings returns a noop.SettingsStore if the context has no organization specified -// and a organization.SettingsStore otherwise. -func (s *Store) Settings(ctx context.Context) chronograf.SettingsStore { +// OrganizationConfig returns a noop.OrganizationConfigStore if the context has no organization specified +// and an organization.OrganizationConfigStore otherwise. +func (s *Store) OrganizationConfig(ctx context.Context) chronograf.OrganizationConfigStore { if isServer := hasServerContext(ctx); isServer { - return s.SettingsStore + return s.OrganizationConfigStore } - if org, ok := hasOrganizationContext(ctx); ok { - return organizations.NewSettingsStore(s.SettingsStore, org) + if orgID, ok := hasOrganizationContext(ctx); ok { + return organizations.NewOrganizationConfigStore(s.OrganizationConfigStore, orgID) } - return &noop.SettingsStore{} + return &noop.OrganizationConfigStore{} } // Organizations returns the underlying OrganizationsStore.