feat: add new Folder table migration & define nested folder interfaces (#56882)

* feat: add new Folder table migration

Add a new folder table to support the Nested Folders feature.

https://github.com/grafana/grafana/issues/56880

* register nested folders feature flag (unused)

* feat: nested folder service (experiment)

This commit adds a NestedFolderSvc interface and stubbed out implementation as an alternative to the existing folder service. This is an experimental feature to try out different methods for backwards compatibility and parallelization, so that Grafana can continue to store folders in the existing (non-nested) manner while also using the new nested folder service.

Eventually the new service will (hopefully) become _the_ service, at which point the legacy service can be deprecated (or remain, with the new service methods replacing the original. whatever makes sense at the time).


* nested folders: don't run the new migration

This commit removes the nested folder migration from the list of active migrations so we can merge this branch and continue development without impacting Grafana instances built off main.
This commit is contained in:
Kristin Laemmert
2022-10-26 10:15:14 -04:00
committed by GitHub
parent 237ff2699d
commit b346ae0310
15 changed files with 402 additions and 21 deletions
+1
View File
@@ -90,6 +90,7 @@ func (s *Service) GetFolderByID(ctx context.Context, user *user.SignedInUser, id
if id == 0 {
return &models.Folder{Id: id, Title: "General"}, nil
}
dashFolder, err := s.dashboardStore.GetFolderByID(ctx, orgID, id)
if err != nil {
return nil, err
+53
View 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 store struct {
db db.DB
log log.Logger
cfg *setting.Cfg
fm featuremgmt.FeatureManager
}
// store implements the folder.Store interface.
var _ folder.Store = (*store)(nil)
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}
}
func (s *store) Create(ctx context.Context, cmd *folder.CreateFolderCommand) (*folder.Folder, error) {
panic("not implemented")
}
func (s *store) Delete(ctx context.Context, uid string, orgID int64) error {
panic("not implemented")
}
func (s *store) Update(ctx context.Context, cmd *folder.UpdateFolderCommand) (*folder.Folder, error) {
panic("not implemented")
}
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")
}
@@ -0,0 +1,21 @@
package folderimpl
import "testing"
func TestCreate(t *testing.T) {}
func TestDelete(t *testing.T) {}
func TestUpdate(t *testing.T) {}
func TestMove(t *testing.T) {}
func TestGet(t *testing.T) {}
func TestGetParent(t *testing.T) {}
func TestGetParents(t *testing.T) {}
func TestGetChildren(t *testing.T) {}
func TestGetDescendents(t *testing.T) {}