mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
some file moving and struct renaming (#57686)
This commit is contained in:
parent
8917bd57e6
commit
6c982e5b71
53
pkg/services/folder/folderimpl/sqlstore.go
Normal file
53
pkg/services/folder/folderimpl/sqlstore.go
Normal file
@ -0,0 +1,53 @@
|
||||
package folderimpl
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/db"
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/services/folder"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
|
||||
type sqlStore struct {
|
||||
db db.DB
|
||||
log log.Logger
|
||||
cfg *setting.Cfg
|
||||
fm featuremgmt.FeatureManager
|
||||
}
|
||||
|
||||
// sqlStore implements the store interface.
|
||||
var _ store = (*sqlStore)(nil)
|
||||
|
||||
func ProvideStore(db db.DB, cfg *setting.Cfg, features featuremgmt.FeatureManager) *sqlStore {
|
||||
return &sqlStore{db: db, log: log.New("folder-store"), cfg: cfg, fm: features}
|
||||
}
|
||||
|
||||
func (s *sqlStore) Create(ctx context.Context, cmd *folder.CreateFolderCommand) (*folder.Folder, error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (s *sqlStore) Delete(ctx context.Context, uid string, orgID int64) error {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (s *sqlStore) Update(ctx context.Context, cmd *folder.UpdateFolderCommand) (*folder.Folder, error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (s *sqlStore) Move(ctx context.Context, cmd *folder.MoveFolderCommand) (*folder.Folder, error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (s *sqlStore) Get(ctx context.Context, cmd *folder.GetFolderQuery) (*folder.Folder, error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (s *sqlStore) GetParents(ctx context.Context, cmd *folder.GetParentsQuery) ([]*folder.Folder, error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (s *sqlStore) GetChildren(ctx context.Context, cmd *folder.GetTreeQuery) ([]*folder.Folder, error) {
|
||||
panic("not implemented")
|
||||
}
|
@ -3,51 +3,31 @@ package folderimpl
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/grafana/grafana/pkg/infra/db"
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/services/folder"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
|
||||
type store struct {
|
||||
db db.DB
|
||||
log log.Logger
|
||||
cfg *setting.Cfg
|
||||
fm featuremgmt.FeatureManager
|
||||
}
|
||||
// Store is the interface which a folder store must implement.
|
||||
type store interface {
|
||||
// Create creates a folder and returns the newly-created folder.
|
||||
Create(ctx context.Context, cmd *folder.CreateFolderCommand) (*folder.Folder, error)
|
||||
|
||||
// store implements the folder.Store interface.
|
||||
var _ folder.Store = (*store)(nil)
|
||||
// Delete deletes a folder from the folder store.
|
||||
Delete(ctx context.Context, uid string, orgID int64) error
|
||||
|
||||
func ProvideStore(db db.DB, cfg *setting.Cfg, features featuremgmt.FeatureManager) *store {
|
||||
return &store{db: db, log: log.New("folder-store"), cfg: cfg, fm: features}
|
||||
}
|
||||
// Update updates the given folder's UID, Title, and Description.
|
||||
// Use Move to change a dashboard's parent ID.
|
||||
Update(ctx context.Context, cmd *folder.UpdateFolderCommand) (*folder.Folder, error)
|
||||
|
||||
func (s *store) Create(ctx context.Context, cmd *folder.CreateFolderCommand) (*folder.Folder, error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
// Move changes the given folder's parent folder uid and applies any necessary permissions changes.
|
||||
Move(ctx context.Context, cmd *folder.MoveFolderCommand) (*folder.Folder, error)
|
||||
|
||||
func (s *store) Delete(ctx context.Context, uid string, orgID int64) error {
|
||||
panic("not implemented")
|
||||
}
|
||||
// Get returns a folder.
|
||||
Get(ctx context.Context, cmd *folder.GetFolderQuery) (*folder.Folder, error)
|
||||
|
||||
func (s *store) Update(ctx context.Context, cmd *folder.UpdateFolderCommand) (*folder.Folder, error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
// GetParents returns an ordered list of parent folder of the given folder.
|
||||
GetParents(ctx context.Context, cmd *folder.GetParentsQuery) ([]*folder.Folder, error)
|
||||
|
||||
func (s *store) Move(ctx context.Context, cmd *folder.MoveFolderCommand) (*folder.Folder, error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (s *store) Get(ctx context.Context, cmd *folder.GetFolderCommand) (*folder.Folder, error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (s *store) GetParents(ctx context.Context, cmd *folder.GetParentsCommand) ([]*folder.Folder, error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (s *store) GetChildren(ctx context.Context, cmd *folder.GetTreeCommand) ([]*folder.Folder, error) {
|
||||
panic("not implemented")
|
||||
// GetChildren returns the set of immediate children folders (depth=1) of the
|
||||
// given folder.
|
||||
GetChildren(ctx context.Context, cmd *folder.GetTreeQuery) ([]*folder.Folder, error)
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package foldertest
|
||||
package folderimpl
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -12,7 +12,7 @@ type FakeStore struct {
|
||||
ExpectedError error
|
||||
}
|
||||
|
||||
var _ folder.Store = (*FakeStore)(nil)
|
||||
var _ store = (*FakeStore)(nil)
|
||||
|
||||
func (f *FakeStore) Create(ctx context.Context, cmd *folder.CreateFolderCommand) (*folder.Folder, error) {
|
||||
return f.ExpectedFolder, f.ExpectedError
|
||||
@ -30,14 +30,14 @@ func (f *FakeStore) Move(ctx context.Context, cmd *folder.MoveFolderCommand) (*f
|
||||
return f.ExpectedFolder, f.ExpectedError
|
||||
}
|
||||
|
||||
func (f *FakeStore) Get(ctx context.Context, cmd *folder.GetFolderCommand) (*folder.Folder, error) {
|
||||
func (f *FakeStore) Get(ctx context.Context, cmd *folder.GetFolderQuery) (*folder.Folder, error) {
|
||||
return f.ExpectedFolder, f.ExpectedError
|
||||
}
|
||||
|
||||
func (f *FakeStore) GetParents(ctx context.Context, cmd *folder.GetParentsCommand) ([]*folder.Folder, error) {
|
||||
func (f *FakeStore) GetParents(ctx context.Context, cmd *folder.GetParentsQuery) ([]*folder.Folder, error) {
|
||||
return f.ExpectedFolders, f.ExpectedError
|
||||
}
|
||||
|
||||
func (f *FakeStore) GetChildren(ctx context.Context, cmd *folder.GetTreeCommand) ([]*folder.Folder, error) {
|
||||
func (f *FakeStore) GetChildren(ctx context.Context, cmd *folder.GetTreeQuery) ([]*folder.Folder, error) {
|
||||
return f.ExpectedFolders, f.ExpectedError
|
||||
}
|
@ -71,26 +71,26 @@ type DeleteFolderCommand struct {
|
||||
UID string `json:"uid"`
|
||||
}
|
||||
|
||||
// GetFolderCommand is used for all folder Get requests. Only one of UID, ID, or
|
||||
// GetFolderQuery is used for all folder Get requests. Only one of UID, ID, or
|
||||
// Title should be set; if multilpe fields are set by the caller the dashboard
|
||||
// service will select the field with the most specificity, in order: ID, UID,
|
||||
// Title.
|
||||
type GetFolderCommand struct {
|
||||
type GetFolderQuery struct {
|
||||
UID *string
|
||||
ID *int
|
||||
Title *string
|
||||
}
|
||||
|
||||
// GetParentsCommand captures the information required by the folder service to
|
||||
// GetParentsQuery captures the information required by the folder service to
|
||||
// return a list of all parent folders of a given folder.
|
||||
type GetParentsCommand struct {
|
||||
type GetParentsQuery struct {
|
||||
UID string
|
||||
}
|
||||
|
||||
// GetTreeCommand captures the information required by the folder service to
|
||||
// return a list of child folders of the given folder.
|
||||
|
||||
type GetTreeCommand struct {
|
||||
type GetTreeQuery struct {
|
||||
UID string
|
||||
Depth int64
|
||||
|
||||
|
@ -42,12 +42,12 @@ type NestedFolderService interface {
|
||||
// request. One of ID, UID, or Title must be included. If multiple values
|
||||
// are included in the request, Grafana will select one in order of
|
||||
// specificity (ID, UID, Title).
|
||||
Get(ctx context.Context, cmd *GetFolderCommand) (*Folder, error)
|
||||
Get(ctx context.Context, cmd *GetFolderQuery) (*Folder, error)
|
||||
|
||||
// GetParents returns an ordered list of parent folders for the given
|
||||
// folder, starting with the root node and ending with the requested child
|
||||
// node.
|
||||
GetParents(ctx context.Context, cmd *GetParentsCommand) ([]*Folder, error)
|
||||
GetParents(ctx context.Context, cmd *GetParentsQuery) ([]*Folder, error)
|
||||
|
||||
// GetTree returns an map containing all child folders starting from the
|
||||
// given parent folder UID and descending to the requested depth. Use the
|
||||
@ -55,5 +55,5 @@ type NestedFolderService interface {
|
||||
//
|
||||
// The map keys are folder uids and the values are the list of child folders
|
||||
// for that parent.
|
||||
GetTree(ctx context.Context, cmd *GetTreeCommand) (map[string][]*Folder, error)
|
||||
GetTree(ctx context.Context, cmd *GetTreeQuery) (map[string][]*Folder, error)
|
||||
}
|
||||
|
@ -1,29 +0,0 @@
|
||||
package folder
|
||||
|
||||
import "context"
|
||||
|
||||
// Store is the interface which a folder store must implement.
|
||||
type Store interface {
|
||||
// Create creates a folder and returns the newly-created folder.
|
||||
Create(ctx context.Context, cmd *CreateFolderCommand) (*Folder, error)
|
||||
|
||||
// Delete deletes a folder from the folder store.
|
||||
Delete(ctx context.Context, uid string, orgID int64) error
|
||||
|
||||
// Update updates the given folder's UID, Title, and Description.
|
||||
// Use Move to change a dashboard's parent ID.
|
||||
Update(ctx context.Context, cmd *UpdateFolderCommand) (*Folder, error)
|
||||
|
||||
// Move changes the given folder's parent folder uid and applies any necessary permissions changes.
|
||||
Move(ctx context.Context, cmd *MoveFolderCommand) (*Folder, error)
|
||||
|
||||
// Get returns a folder.
|
||||
Get(ctx context.Context, cmd *GetFolderCommand) (*Folder, error)
|
||||
|
||||
// GetParents returns an ordered list of parent folder of the given folder.
|
||||
GetParents(ctx context.Context, cmd *GetParentsCommand) ([]*Folder, error)
|
||||
|
||||
// GetChildren returns the set of immediate children folders (depth=1) of the
|
||||
// given folder.
|
||||
GetChildren(ctx context.Context, cmd *GetTreeCommand) ([]*Folder, error)
|
||||
}
|
Loading…
Reference in New Issue
Block a user