K8s: Folders: Modify GetChildren to return only Folder References (#103072)

* Return FolderReference instead of Folder on GetChildren

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>

---------

Signed-off-by: Maicon Costa <maiconscosta@gmail.com>
This commit is contained in:
maicon
2025-04-02 01:30:17 -03:00
committed by GitHub
parent 654afbcfa2
commit d8c5c2d3b8
24 changed files with 107 additions and 104 deletions
+22 -3
View File
@@ -63,6 +63,18 @@ type Folder struct {
ManagedBy utils.ManagerKind `json:"managedBy,omitempty"`
}
type FolderReference struct {
// Deprecated: use UID instead
ID int64 `xorm:"pk autoincr 'id'"`
UID string `xorm:"uid"`
Title string
ParentUID string `xorm:"parent_uid"`
// When the folder belongs to a repository
// NOTE: this is only populated when folders are managed by unified storage
ManagedBy utils.ManagerKind `json:"managedBy,omitempty"`
}
var GeneralFolder = Folder{ID: 0, Title: "General"}
var RootFolder = &Folder{ID: 0, Title: "Dashboards", UID: GeneralFolderUID, ParentUID: ""}
var SharedWithMeFolder = Folder{
@@ -89,6 +101,16 @@ func (f *Folder) WithURL() *Folder {
return f
}
func (f *Folder) ToFolderReference() *FolderReference {
return &FolderReference{
ID: f.ID,
UID: f.UID,
Title: f.Title,
ParentUID: f.ParentUID,
ManagedBy: f.ManagedBy,
}
}
// NewFolder tales a title and returns a Folder with the Created and Updated
// fields set to the current time.
func NewFolder(title string, description string) *Folder {
@@ -221,9 +243,6 @@ type GetChildrenQuery struct {
// array of folder uids to filter by
FolderUIDs []string `json:"-"`
// Deprecated: this is a temporary flag, and will be removed once we migrate the alerting use case
RefOnly bool
}
type HasEditPermissionInFoldersQuery struct {