revert: remove slugification from folder paths

- Keep folder paths with spaces as-is, matching folder titles
- Update test expectation to use 'Test Export Folder' instead of 'test-export-folder'
- Remove unused slugify import
- Folder paths should preserve original folder titles
This commit is contained in:
Roberto Jimenez Sanchez
2025-12-02 22:28:54 +01:00
parent 4f292a3ecd
commit 0aaf6402f1
2 changed files with 5 additions and 8 deletions
@@ -15,7 +15,6 @@ import (
"github.com/grafana/grafana/apps/provisioning/pkg/repository"
"github.com/grafana/grafana/apps/provisioning/pkg/safepath"
"github.com/grafana/grafana/pkg/apimachinery/utils"
"github.com/grafana/grafana/pkg/infra/slugify"
"github.com/grafana/grafana/pkg/registry/apis/provisioning/jobs"
"github.com/grafana/grafana/pkg/registry/apis/provisioning/resources"
)
@@ -358,12 +357,10 @@ func computeExportPath(basePath string, meta utils.GrafanaMetaAccessor, tree res
// Get the folder path from the unmanaged tree (rootFolder is empty string for unmanaged tree)
fid, ok := tree.DirPath(resourceFolder, "")
if ok && fid.Path != "" {
// Slugify the folder path to match file system conventions
slugifiedPath := slugify.Slugify(fid.Path)
if exportPath != "" {
exportPath = safepath.Join(exportPath, slugifiedPath)
exportPath = safepath.Join(exportPath, fid.Path)
} else {
exportPath = slugifiedPath
exportPath = fid.Path
}
}
}
@@ -230,7 +230,7 @@ func TestIntegrationProvisioning_ExportSpecificResourcesRejectsManagedResources(
"exportunifiedtorepository/dashboard-test-v1.yaml": "dashboard.json",
},
ExpectedDashboards: 1,
ExpectedFolders: 1, // Folder target creates a folder with the repo name
ExpectedFolders: 1, // Folder target creates a folder with the repo name
SkipResourceAssertions: true, // Skip assertions since we're testing export, not sync
}
helper.CreateRepo(t, testRepo)
@@ -366,8 +366,8 @@ func TestIntegrationProvisioning_ExportSpecificResourcesWithFolderStructure(t *t
// Verify dashboard was exported with folder structure
// The folder path should be included in the file path based on the folder title
// Folder title is "Test Export Folder", which gets slugified to "test-export-folder"
expectedFile := filepath.Join(helper.ProvisioningPath, "test-export-folder", "test-dashboard-created-at-v1.json")
// Folder title is "Test Export Folder", which is used as-is (with spaces)
expectedFile := filepath.Join(helper.ProvisioningPath, "Test Export Folder", "test-dashboard-created-at-v1.json")
body, err := os.ReadFile(expectedFile) //nolint:gosec
require.NoError(t, err, "exported file should exist with folder structure")
obj := map[string]any{}