unified-storage: Reduce calls to the user service (#102934)

* Create ListByIdOrUID in user service

* create UnstructuredToLegacyFolderList 

* update GetFolders to use list parser

* update GetDescendants to use list parser

* update UnstructuredToLegacyFolder to also make a single call to the user service

---------

Co-authored-by: Stephanie Hingtgen <stephanie.hingtgen@grafana.com>
This commit is contained in:
Will Assis
2025-03-27 17:01:07 -03:00
committed by GitHub
parent 7e3efb3df2
commit 51825cfffe
13 changed files with 643 additions and 63 deletions

View File

@ -11,6 +11,7 @@ import (
"github.com/grafana/grafana/pkg/services/apiserver/client"
"github.com/grafana/grafana/pkg/services/dashboards"
"github.com/grafana/grafana/pkg/services/folder"
"github.com/grafana/grafana/pkg/services/user/usertest"
"github.com/grafana/grafana/pkg/storage/unified/resource"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
@ -93,7 +94,8 @@ func TestComputeFullPath(t *testing.T) {
func TestGetParents(t *testing.T) {
mockCli := new(client.MockK8sHandler)
store := FolderUnifiedStoreImpl{
k8sclient: mockCli,
k8sclient: mockCli,
userService: usertest.NewUserServiceFake(),
}
ctx := context.Background()
@ -187,7 +189,8 @@ func TestGetParents(t *testing.T) {
func TestGetChildren(t *testing.T) {
mockCli := new(client.MockK8sHandler)
store := FolderUnifiedStoreImpl{
k8sclient: mockCli,
k8sclient: mockCli,
userService: usertest.NewUserServiceFake(),
}
ctx := context.Background()