Schema: Add basic folder schema (#67561)

This commit is contained in:
Ryan McKinley
2023-05-03 13:07:39 -07:00
committed by GitHub
parent 5765514397
commit 881ed3b599
11 changed files with 381 additions and 4 deletions
+14
View File
@@ -13,6 +13,7 @@ import (
"fmt"
"github.com/grafana/grafana/pkg/kinds/dashboard"
"github.com/grafana/grafana/pkg/kinds/folder"
"github.com/grafana/grafana/pkg/kinds/librarypanel"
"github.com/grafana/grafana/pkg/kinds/playlist"
"github.com/grafana/grafana/pkg/kinds/preferences"
@@ -41,6 +42,7 @@ import (
type Base struct {
all []kindsys.Core
dashboard *dashboard.Kind
folder *folder.Kind
librarypanel *librarypanel.Kind
playlist *playlist.Kind
preferences *preferences.Kind
@@ -52,6 +54,7 @@ type Base struct {
// type guards
var (
_ kindsys.Core = &dashboard.Kind{}
_ kindsys.Core = &folder.Kind{}
_ kindsys.Core = &librarypanel.Kind{}
_ kindsys.Core = &playlist.Kind{}
_ kindsys.Core = &preferences.Kind{}
@@ -65,6 +68,11 @@ func (b *Base) Dashboard() *dashboard.Kind {
return b.dashboard
}
// Folder returns the [kindsys.Interface] implementation for the folder kind.
func (b *Base) Folder() *folder.Kind {
return b.folder
}
// LibraryPanel returns the [kindsys.Interface] implementation for the librarypanel kind.
func (b *Base) LibraryPanel() *librarypanel.Kind {
return b.librarypanel
@@ -105,6 +113,12 @@ func doNewBase(rt *thema.Runtime) *Base {
}
reg.all = append(reg.all, reg.dashboard)
reg.folder, err = folder.NewKind(rt)
if err != nil {
panic(fmt.Sprintf("error while initializing the folder Kind: %s", err))
}
reg.all = append(reg.all, reg.folder)
reg.librarypanel, err = librarypanel.NewKind(rt)
if err != nil {
panic(fmt.Sprintf("error while initializing the librarypanel Kind: %s", err))