Wire up bolt db ConfigStore in Server

pull/10616/head
Michael Desa 2017-12-13 10:46:08 -08:00
parent 331fa6f897
commit c718847014
3 changed files with 34 additions and 2 deletions

26
noop/config.go Normal file
View File

@ -0,0 +1,26 @@
package noop
import (
"context"
"fmt"
"github.com/influxdata/chronograf"
)
// ensure ConfigStore implements chronograf.ConfigStore
var _ chronograf.ConfigStore = &ConfigStore{}
type ConfigStore struct{}
// TODO(desa): this really should be removed
func (s *ConfigStore) Initialize(context.Context) error {
return fmt.Errorf("cannot initialize")
}
func (s *ConfigStore) Get(context.Context) (*chronograf.Config, error) {
return nil, chronograf.ErrConfigNotFound
}
func (s *ConfigStore) Update(context.Context, *chronograf.Config) error {
return fmt.Errorf("cannot update conifg")
}

View File

@ -441,7 +441,7 @@ func openService(ctx context.Context, boltPath string, lBuilder LayoutBuilder, s
OrganizationsStore: db.OrganizationsStore,
LayoutsStore: layouts,
DashboardsStore: db.DashboardsStore,
//OrganizationUsersStore: organizations.NewUsersStore(db.UsersStore),
ConfigStore: db.ConfigStore,
},
Logger: logger,
UseAuth: useAuth,

View File

@ -183,5 +183,11 @@ func (s *Store) Organizations(ctx context.Context) chronograf.OrganizationsStore
// Config returns the underlying ConfigStore.
func (s *Store) Config(ctx context.Context) chronograf.ConfigStore {
return nil
if isServer := hasServerContext(ctx); isServer {
return s.ConfigStore
}
if isSuperAdmin := hasSuperAdminContext(ctx); isSuperAdmin {
return s.ConfigStore
}
return &noop.ConfigStore{}
}