Documentation ¶
Overview ¶
Package filestore provides the ability to read pre-defined resources from a specified directory (--canned-path). This also provides a means to make updates to certain resources. Adding new resources is not supported as it paves the way for too much unexpected behaviors. Filestore is used in conjunction with a 'multistore' and is usually tried last. By supporting add functionality, a resource may mistakenly be saved to the filesystem if the write to the db fails.
Resources that are storable in a file are: (CRUD refers to create, read, update, delete. An '_' means not supported)
Apps(layouts) - _R__ Dashboards - _RUD Kapacitors - _RUD Organizations - _R__ Protoboards - _R__ Sources - _RUD
Caution should be taken when editing resources provided via the filestore, especially in a distributed environment as unexpected behavior may occur.
Index ¶
- Constants
- func NewApps(dir string, ids chronograf.ID, logger chronograf.Logger) chronograf.LayoutsStore
- func NewDashboards(dir string, logger chronograf.Logger) chronograf.DashboardsStore
- func NewKapacitors(dir string, ids chronograf.ID, logger chronograf.Logger) chronograf.ServersStore
- func NewOrganizations(dir string, logger chronograf.Logger) chronograf.OrganizationsStore
- func NewProtoboards(dir string, ids chronograf.ID, logger chronograf.Logger) chronograf.ProtoboardsStore
- func NewSources(dir string, ids chronograf.ID, logger chronograf.Logger) chronograf.SourcesStore
- type Apps
- type Dashboards
- func (d *Dashboards) Add(ctx context.Context, dashboard chronograf.Dashboard) (chronograf.Dashboard, error)
- func (d *Dashboards) All(ctx context.Context) ([]chronograf.Dashboard, error)
- func (d *Dashboards) Delete(ctx context.Context, dashboard chronograf.Dashboard) error
- func (d *Dashboards) Get(ctx context.Context, id chronograf.DashboardID) (chronograf.Dashboard, error)
- func (d *Dashboards) Update(ctx context.Context, dashboard chronograf.Dashboard) error
- type Kapacitors
- func (d *Kapacitors) Add(ctx context.Context, kapacitor chronograf.Server) (chronograf.Server, error)
- func (d *Kapacitors) All(ctx context.Context) ([]chronograf.Server, error)
- func (d *Kapacitors) Delete(ctx context.Context, kapacitor chronograf.Server) error
- func (d *Kapacitors) Get(ctx context.Context, id int) (chronograf.Server, error)
- func (d *Kapacitors) Update(ctx context.Context, kapacitor chronograf.Server) error
- type Organizations
- func (o *Organizations) Add(ctx context.Context, org *chronograf.Organization) (*chronograf.Organization, error)
- func (o *Organizations) All(ctx context.Context) ([]chronograf.Organization, error)
- func (o *Organizations) CreateDefault(ctx context.Context) error
- func (o *Organizations) DefaultOrganization(ctx context.Context) (*chronograf.Organization, error)
- func (o *Organizations) Delete(ctx context.Context, org *chronograf.Organization) error
- func (o *Organizations) Get(ctx context.Context, query chronograf.OrganizationQuery) (*chronograf.Organization, error)
- func (o *Organizations) Update(ctx context.Context, org *chronograf.Organization) error
- type Protoboards
- type Sources
- func (d *Sources) Add(ctx context.Context, source chronograf.Source) (chronograf.Source, error)
- func (d *Sources) All(ctx context.Context) ([]chronograf.Source, error)
- func (d *Sources) Delete(ctx context.Context, source chronograf.Source) error
- func (d *Sources) Get(ctx context.Context, id int) (chronograf.Source, error)
- func (d *Sources) Update(ctx context.Context, source chronograf.Source) error
Constants ¶
const AppExt = ".json"
AppExt is the the file extension searched for in the directory for layout files
const DashExt = ".dashboard"
DashExt is the the file extension searched for in the directory for dashboard files
const KapExt = ".kap"
KapExt is the the file extension searched for in the directory for kapacitor files
const OrgExt = ".org"
OrgExt is the the file extension searched for in the directory for org files
const ProtoboardExt = ".json"
ProtoboardExt is the the file extension searched for in the directory for protoboard files
const SrcExt = ".src"
SrcExt is the the file extension searched for in the directory for source files
Variables ¶
This section is empty.
Functions ¶
func NewApps ¶
func NewApps(dir string, ids chronograf.ID, logger chronograf.Logger) chronograf.LayoutsStore
NewApps constructs a layout store wrapping a file system directory
func NewDashboards ¶
func NewDashboards(dir string, logger chronograf.Logger) chronograf.DashboardsStore
NewDashboards constructs a dashboard store wrapping a file system directory
func NewKapacitors ¶
func NewKapacitors(dir string, ids chronograf.ID, logger chronograf.Logger) chronograf.ServersStore
NewKapacitors constructs a kapacitor store wrapping a file system directory
func NewOrganizations ¶
func NewOrganizations(dir string, logger chronograf.Logger) chronograf.OrganizationsStore
NewOrganizations constructs a org store wrapping a file system directory
func NewProtoboards ¶
func NewProtoboards(dir string, ids chronograf.ID, logger chronograf.Logger) chronograf.ProtoboardsStore
NewProtoboards constructs a protoboard store wrapping a file system directory
func NewSources ¶
func NewSources(dir string, ids chronograf.ID, logger chronograf.Logger) chronograf.SourcesStore
NewSources constructs a source store wrapping a file system directory
Types ¶
type Apps ¶
type Apps struct { Dir string // Dir is the directory contained the pre-canned applications. Load func(string) (chronograf.Layout, error) // Load loads string name and return a Layout ReadDir func(dirname string) ([]os.FileInfo, error) // ReadDir reads the directory named by dirname and returns a list of directory entries sorted by filename. IDs chronograf.ID // IDs generate unique ids for new application layouts Logger chronograf.Logger }
Apps are canned JSON layouts. Implements LayoutsStore.
type Dashboards ¶
type Dashboards struct { Dir string // Dir is the directory containing the dashboards. ReadDir func(dirname string) ([]os.FileInfo, error) // ReadDir reads the directory named by dirname and returns a list of directory entries sorted by filename. Remove func(name string) error // Remove file Logger chronograf.Logger }
Dashboards are JSON dashboards stored in the filesystem
func (*Dashboards) Add ¶
func (d *Dashboards) Add(ctx context.Context, dashboard chronograf.Dashboard) (chronograf.Dashboard, error)
Add creates a new dashboard within the directory
func (*Dashboards) All ¶
func (d *Dashboards) All(ctx context.Context) ([]chronograf.Dashboard, error)
All returns all dashboards from the directory
func (*Dashboards) Delete ¶
func (d *Dashboards) Delete(ctx context.Context, dashboard chronograf.Dashboard) error
Delete removes a dashboard file from the directory
func (*Dashboards) Get ¶
func (d *Dashboards) Get(ctx context.Context, id chronograf.DashboardID) (chronograf.Dashboard, error)
Get returns a dashboard file from the dashboard directory
func (*Dashboards) Update ¶
func (d *Dashboards) Update(ctx context.Context, dashboard chronograf.Dashboard) error
Update replaces a dashboard from the file system directory
type Kapacitors ¶
type Kapacitors struct { Dir string // Dir is the directory containing the kapacitors. ReadDir func(dirname string) ([]os.FileInfo, error) // ReadDir reads the directory named by dirname and returns a list of directory entries sorted by filename. Remove func(name string) error // Remove file IDs chronograf.ID // IDs generate unique ids for new kapacitors Logger chronograf.Logger }
Kapacitors are JSON kapacitors stored in the filesystem
func (*Kapacitors) Add ¶
func (d *Kapacitors) Add(ctx context.Context, kapacitor chronograf.Server) (chronograf.Server, error)
Add creates a new kapacitor within the directory
func (*Kapacitors) All ¶
func (d *Kapacitors) All(ctx context.Context) ([]chronograf.Server, error)
All returns all kapacitors from the directory
func (*Kapacitors) Delete ¶
func (d *Kapacitors) Delete(ctx context.Context, kapacitor chronograf.Server) error
Delete removes a kapacitor file from the directory
func (*Kapacitors) Get ¶
func (d *Kapacitors) Get(ctx context.Context, id int) (chronograf.Server, error)
Get returns a kapacitor file from the kapacitor directory
func (*Kapacitors) Update ¶
func (d *Kapacitors) Update(ctx context.Context, kapacitor chronograf.Server) error
Update replaces a kapacitor from the file system directory
type Organizations ¶
type Organizations struct { Dir string // Dir is the directory containing the orgs. Load func(string, interface{}) error // Load loads string name and org passed in as interface ReadDir func(dirname string) ([]os.FileInfo, error) // ReadDir reads the directory named by dirname and returns a list of directory entries sorted by filename. Logger chronograf.Logger }
Organizations are JSON orgs stored in the filesystem
func (*Organizations) Add ¶
func (o *Organizations) Add(ctx context.Context, org *chronograf.Organization) (*chronograf.Organization, error)
Add is not allowed for the filesystem organization store
func (*Organizations) All ¶
func (o *Organizations) All(ctx context.Context) ([]chronograf.Organization, error)
All returns all orgs from the directory
func (*Organizations) CreateDefault ¶
func (o *Organizations) CreateDefault(ctx context.Context) error
CreateDefault is not allowed for the filesystem organization store
func (*Organizations) DefaultOrganization ¶
func (o *Organizations) DefaultOrganization(ctx context.Context) (*chronograf.Organization, error)
DefaultOrganization is not allowed for the filesystem organization store
func (*Organizations) Delete ¶
func (o *Organizations) Delete(ctx context.Context, org *chronograf.Organization) error
Delete is not allowed for the filesystem organization store
func (*Organizations) Get ¶
func (o *Organizations) Get(ctx context.Context, query chronograf.OrganizationQuery) (*chronograf.Organization, error)
Get returns a org file from the org directory
func (*Organizations) Update ¶
func (o *Organizations) Update(ctx context.Context, org *chronograf.Organization) error
Update is not allowed for the filesystem organization store
type Protoboards ¶
type Protoboards struct { Dir string // Dir is the directory containing protoboard json definitions Load func(string) (chronograf.Protoboard, error) // Load receives filename, returns a Protoboard from json file ReadDir func(dirname string) ([]os.FileInfo, error) // ReadDir reads the directory named by dirname and returns a list of directory entries sorted by filename. IDs chronograf.ID // ID generates unique ids for new protoboards Logger chronograf.Logger }
Protoboards are instantiable JSON representation of dashbards. Implements ProtoboardsStore.
func (*Protoboards) All ¶
func (a *Protoboards) All(ctx context.Context) ([]chronograf.Protoboard, error)
All returns all protoboards from the directory
func (*Protoboards) Get ¶
func (a *Protoboards) Get(ctx context.Context, ID string) (chronograf.Protoboard, error)
Get returns a protoboard file from the protoboard directory
type Sources ¶
type Sources struct { Dir string // Dir is the directory containing the sources. ReadDir func(dirname string) ([]os.FileInfo, error) // ReadDir reads the directory named by dirname and returns a list of directory entries sorted by filename. Remove func(name string) error // Remove file IDs chronograf.ID // IDs generate unique ids for new sources Logger chronograf.Logger }
Sources are JSON sources stored in the filesystem
func (*Sources) Add ¶
func (d *Sources) Add(ctx context.Context, source chronograf.Source) (chronograf.Source, error)
Add creates a new source within the directory