From 614248c63dc285faf8bfd65829163e47f07f9d2b Mon Sep 17 00:00:00 2001 From: Ryan McKinley Date: Tue, 2 Dec 2025 16:28:45 +0300 Subject: [PATCH] annotations --- pkg/services/folder/folderimpl/conversions.go | 2 +- pkg/services/folder/folderimpl/unifiedstore.go | 2 +- pkg/tests/apis/folder/folder_tree_test.go | 7 ++++--- pkg/tests/apis/folder/folders_test.go | 6 +++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pkg/services/folder/folderimpl/conversions.go b/pkg/services/folder/folderimpl/conversions.go index ebb313dfade..57ba4fa8f2a 100644 --- a/pkg/services/folder/folderimpl/conversions.go +++ b/pkg/services/folder/folderimpl/conversions.go @@ -32,7 +32,7 @@ func convertUnstructuredToFolder(item *unstructured.Unstructured, identifiers ma uid := meta.GetName() url := "" - if uid != folder.RootFolder.UID { + if !folder.IsRootFolder(uid) { slug := slugify.Slugify(title) url = dashboards.GetFolderURL(uid, slug) } diff --git a/pkg/services/folder/folderimpl/unifiedstore.go b/pkg/services/folder/folderimpl/unifiedstore.go index 4e2aa02343e..e168c8ea66e 100644 --- a/pkg/services/folder/folderimpl/unifiedstore.go +++ b/pkg/services/folder/folderimpl/unifiedstore.go @@ -180,7 +180,7 @@ func (ss *FolderUnifiedStoreImpl) GetParents(ctx context.Context, q folder.GetPa hits := []*folder.Folder{} parentUID := q.UID - for parentUID != "" { + for !folder.IsRootFolder(parentUID) { folder, err := ss.Get(ctx, folder.GetFolderQuery{UID: &parentUID, OrgID: q.OrgID}) if err != nil { if apierrors.IsForbidden(err) { diff --git a/pkg/tests/apis/folder/folder_tree_test.go b/pkg/tests/apis/folder/folder_tree_test.go index b1d38ab3918..ce1b336c07c 100644 --- a/pkg/tests/apis/folder/folder_tree_test.go +++ b/pkg/tests/apis/folder/folder_tree_test.go @@ -9,6 +9,7 @@ import ( "strings" "testing" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/xlab/treeprint" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -376,7 +377,7 @@ func getFoldersFromLegacyAPISearch(t *testing.T, client *rest.RESTClient) *Folde result = client.Get().AbsPath("api", "folders", hit.UID). Do(context.Background()). StatusCode(&statusCode) - require.NoError(t, result.Error(), "getting folder access info (/api)") + assert.NoError(t, result.Error(), "getting folder access info (/api) uid:%s", hit.UID) require.Equal(t, int(http.StatusOK), statusCode) body, err := result.Raw() @@ -393,7 +394,7 @@ func makeRoot(lookup map[string]*FolderView, name string) *FolderView { shared := &FolderView{} // when not found root := &FolderView{} for _, v := range lookup { - if v.Parent == "" { + if folder.IsRootFolder(v.Parent) { // general or empty root.Children = append(root.Children, v) } else { p, ok := lookup[v.Parent] @@ -444,7 +445,7 @@ func getFoldersFromDashboardV0Search(t *testing.T, client *rest.RESTClient, ns s folderV1.APIVersion, "namespaces", ns, "folders", hit.Name, "access"). Do(context.Background()). StatusCode(&statusCode) - require.NoError(t, result.Error(), "getting folder access info (/access)") + require.NoError(t, result.Error(), "getting folder access info (/access) name:%s", hit.Name) require.Equal(t, int(http.StatusOK), statusCode) body, err := result.Raw() diff --git a/pkg/tests/apis/folder/folders_test.go b/pkg/tests/apis/folder/folders_test.go index 21a0acc2a9d..db7333400b0 100644 --- a/pkg/tests/apis/folder/folders_test.go +++ b/pkg/tests/apis/folder/folders_test.go @@ -134,9 +134,9 @@ func TestIntegrationFoldersApp(t *testing.T) { // test on all dual writer modes modes := []grafanarest.DualWriterMode{ - grafanarest.Mode1, - grafanarest.Mode2, - grafanarest.Mode3, + grafanarest.Mode0, // legacy only + grafanarest.Mode2, // write both, read legacy + grafanarest.Mode3, // write both, read unified grafanarest.Mode4, } for _, modeDw := range modes {