fix(export): slugify folder paths in computeExportPath
- Slugify folder paths when computing export path to match file system conventions - Folder titles from DirPath need to be slugified before use in file paths - This fixes the folder structure export test
This commit is contained in:
@@ -15,6 +15,7 @@ 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"
|
||||
)
|
||||
@@ -357,10 +358,12 @@ 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, fid.Path)
|
||||
exportPath = safepath.Join(exportPath, slugifiedPath)
|
||||
} else {
|
||||
exportPath = fid.Path
|
||||
exportPath = slugifiedPath
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user