remove from legacy folder api

This commit is contained in:
Ryan McKinley
2025-12-02 15:47:47 +03:00
parent 53eead1fa5
commit ba038e2848
3 changed files with 16 additions and 6 deletions
@@ -62,13 +62,18 @@ func convertUnstructuredToFolder(item *unstructured.Unstructured, identifiers ma
}
}
parent := meta.GetFolder()
if folder.IsRootFolder(parent) {
parent = ""
}
manager, _ := meta.GetManagerProperties()
return &folder.Folder{
UID: uid,
Title: title,
Description: description,
ID: meta.GetDeprecatedInternalID(), // nolint:staticcheck
ParentUID: meta.GetFolder(),
ParentUID: parent,
Version: int(meta.GetGeneration()),
ManagedBy: manager.Kind,
+1 -1
View File
@@ -1384,7 +1384,7 @@ func SplitFullpath(s string) []string {
func (s *Service) nestedFolderCreate(ctx context.Context, cmd *folder.CreateFolderCommand) (*folder.Folder, error) {
ctx, span := s.tracer.Start(ctx, "folder.nestedFolderCreate")
defer span.End()
if cmd.ParentUID != "" {
if !folder.IsRootFolder(cmd.ParentUID) {
if err := s.validateParent(ctx, cmd.OrgID, cmd.ParentUID, cmd.UID); err != nil {
return nil, err
}
+9 -4
View File
@@ -14,7 +14,6 @@ import (
"time"
"github.com/google/uuid"
"github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -23,6 +22,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"github.com/grafana/grafana/apps/dashboard/pkg/apis/dashboard/v0alpha1"
folders "github.com/grafana/grafana/apps/folder/pkg/apis/folder/v1beta1"
"github.com/grafana/grafana/pkg/api/dtos"
grafanarest "github.com/grafana/grafana/pkg/apiserver/rest"
@@ -132,9 +132,14 @@ func TestIntegrationFoldersApp(t *testing.T) {
}`, string(v1Disco))
})
// test on all dualwriter modes
for mode := 0; mode <= 4; mode++ {
modeDw := grafanarest.DualWriterMode(mode)
// test on all dual writer modes
modes := []grafanarest.DualWriterMode{
grafanarest.Mode1,
grafanarest.Mode2,
grafanarest.Mode3,
grafanarest.Mode4,
}
for _, modeDw := range modes {
t.Run(fmt.Sprintf("with dual write (unified storage, mode %v)", modeDw), func(t *testing.T) {
doFolderTests(t, apis.NewK8sTestHelper(t, testinfra.GrafanaOpts{