Unistore: Avoid circular dependency when injecting restcfgprovider into FolderSvc (#99295)
* Avoid circular dependency when getting a restCfgProvider for Folder Svc Signed-off-by: Maicon Costa <maiconscosta@gmail.com> --------- Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
clientrest "k8s.io/client-go/rest"
|
||||
|
||||
"github.com/grafana/grafana/pkg/apimachinery/identity"
|
||||
"github.com/grafana/grafana/pkg/apis/folder/v0alpha1"
|
||||
@@ -22,6 +23,7 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/acimpl"
|
||||
"github.com/grafana/grafana/pkg/services/accesscontrol/actest"
|
||||
"github.com/grafana/grafana/pkg/services/apiserver/endpoints/request"
|
||||
"github.com/grafana/grafana/pkg/services/dashboards"
|
||||
"github.com/grafana/grafana/pkg/services/featuremgmt"
|
||||
"github.com/grafana/grafana/pkg/services/folder"
|
||||
@@ -31,6 +33,16 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
)
|
||||
|
||||
type rcp struct {
|
||||
Host string
|
||||
}
|
||||
|
||||
func (r rcp) GetRestConfig(ctx context.Context) *clientrest.Config {
|
||||
return &clientrest.Config{
|
||||
Host: r.Host,
|
||||
}
|
||||
}
|
||||
|
||||
func TestIntegrationFolderServiceViaUnifiedStorage(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping integration test")
|
||||
@@ -147,7 +159,18 @@ func TestIntegrationFolderServiceViaUnifiedStorage(t *testing.T) {
|
||||
db, cfg := sqlstore.InitTestDB(t)
|
||||
cfg.AppURL = folderApiServerMock.URL
|
||||
|
||||
unifiedStore := ProvideUnifiedStore(cfg)
|
||||
restCfgProvider := rcp{
|
||||
Host: folderApiServerMock.URL,
|
||||
}
|
||||
|
||||
k8sHandler := &foldk8sHandler{
|
||||
gvr: v0alpha1.FolderResourceInfo.GroupVersionResource(),
|
||||
namespacer: request.GetNamespaceMapper(cfg),
|
||||
cfg: cfg,
|
||||
restConfigProvider: restCfgProvider.GetRestConfig,
|
||||
}
|
||||
|
||||
unifiedStore := ProvideUnifiedStore(k8sHandler)
|
||||
|
||||
ctx := context.Background()
|
||||
usr := &user.SignedInUser{UserID: 1, OrgID: 1, Permissions: map[int64]map[string][]string{
|
||||
|
||||
Reference in New Issue
Block a user