fix: use folder UID instead of name for tree keying
- Change AddUnstructured to use item.GetUID() instead of item.GetName() - This fixes the mismatch where GetFolder() returns UID but tree was keyed by name - Folders in Grafana are identified by UID, so tree should be keyed by UID
This commit is contained in:
@@ -356,7 +356,12 @@ func computeExportPath(basePath string, meta utils.GrafanaMetaAccessor, tree res
|
||||
if resourceFolder != "" {
|
||||
// Get the folder path from the unmanaged tree (rootFolder is empty string for unmanaged tree)
|
||||
fid, ok := tree.DirPath(resourceFolder, "")
|
||||
if ok && fid.Path != "" {
|
||||
if !ok {
|
||||
// Folder not found in tree - this shouldn't happen for unmanaged folders
|
||||
// but if it does, we'll just use the base path
|
||||
return exportPath
|
||||
}
|
||||
if fid.Path != "" {
|
||||
if exportPath != "" {
|
||||
exportPath = safepath.Join(exportPath, fid.Path)
|
||||
} else {
|
||||
|
||||
@@ -145,9 +145,12 @@ func (t *folderTree) AddUnstructured(item *unstructured.Unstructured) error {
|
||||
return fmt.Errorf("extract meta accessor: %w", err)
|
||||
}
|
||||
|
||||
// Use UID as the identifier since GetFolder() returns UID
|
||||
// In Grafana's folder API, folders are identified by UID
|
||||
folderUID := string(item.GetUID())
|
||||
folder := Folder{
|
||||
Title: meta.FindTitle(item.GetName()),
|
||||
ID: item.GetName(),
|
||||
ID: folderUID,
|
||||
}
|
||||
t.mu.Lock()
|
||||
defer t.mu.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user