playlist: introduce coremodel schema, swap in for backend DTO types (#56048)

* Add simplest possible playlist schema

* Add @grafana(decisionNeeded) attributes

* playlistid, not playlist_id
This commit is contained in:
sam boyer
2022-09-30 06:33:11 -04:00
committed by GitHub
parent d2601003cf
commit 9ec7b202b6
9 changed files with 315 additions and 33 deletions
@@ -10,6 +10,7 @@ import (
"fmt"
"github.com/grafana/grafana/pkg/coremodel/dashboard"
"github.com/grafana/grafana/pkg/coremodel/playlist"
"github.com/grafana/grafana/pkg/coremodel/pluginmeta"
"github.com/grafana/grafana/pkg/framework/coremodel"
"github.com/grafana/thema"
@@ -27,12 +28,14 @@ import (
type Base struct {
all []coremodel.Interface
dashboard *dashboard.Coremodel
playlist *playlist.Coremodel
pluginmeta *pluginmeta.Coremodel
}
// type guards
var (
_ coremodel.Interface = &dashboard.Coremodel{}
_ coremodel.Interface = &playlist.Coremodel{}
_ coremodel.Interface = &pluginmeta.Coremodel{}
)
@@ -42,6 +45,12 @@ func (b *Base) Dashboard() *dashboard.Coremodel {
return b.dashboard
}
// Playlist returns the playlist coremodel. The return value is guaranteed to
// implement coremodel.Interface.
func (b *Base) Playlist() *playlist.Coremodel {
return b.playlist
}
// Pluginmeta returns the pluginmeta coremodel. The return value is guaranteed to
// implement coremodel.Interface.
func (b *Base) Pluginmeta() *pluginmeta.Coremodel {
@@ -58,6 +67,12 @@ func doProvideBase(lib thema.Library) *Base {
}
reg.all = append(reg.all, reg.dashboard)
reg.playlist, err = playlist.New(lib)
if err != nil {
panic(fmt.Sprintf("error while initializing playlist coremodel: %s", err))
}
reg.all = append(reg.all, reg.playlist)
reg.pluginmeta, err = pluginmeta.New(lib)
if err != nil {
panic(fmt.Sprintf("error while initializing pluginmeta coremodel: %s", err))