mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Copy over most of coremodel from intent-api branch * Fix import paths * Fix incorrect provider name * Add root compgen file, fixup componentroot.yaml * go mod tidy * Remove compgen for now * Add dashboard coremodel * Remove datasource coremodel, for now * Tweak comments on dashboard struct model * devenv: add dashboard testing directly * Fixup dashboard schema for openness, heatmap * Update Thema to tip * Fix wire/registry references * Fix hclog version
41 lines
805 B
Go
41 lines
805 B
Go
package dashboard
|
|
|
|
import (
|
|
"github.com/grafana/thema"
|
|
)
|
|
|
|
// Coremodel contains the foundational schema declaration for dashboards.
|
|
type Coremodel struct {
|
|
lin thema.Lineage
|
|
}
|
|
|
|
// Lineage returns the canonical dashboard Lineage.
|
|
func (c *Coremodel) Lineage() thema.Lineage {
|
|
return c.lin
|
|
}
|
|
|
|
func (c *Coremodel) CurrentSchema() thema.Schema {
|
|
sch, err := c.lin.Schema(currentVersion)
|
|
if err != nil {
|
|
// Only reachable if our own schema currentVersion does not exist, which
|
|
// can really only happen transitionally during development
|
|
panic(err)
|
|
}
|
|
return sch
|
|
}
|
|
|
|
func (c *Coremodel) GoType() interface{} {
|
|
return &model{}
|
|
}
|
|
|
|
func ProvideCoremodel(lib thema.Library) (*Coremodel, error) {
|
|
lin, err := Lineage(lib)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &Coremodel{
|
|
lin: lin,
|
|
}, nil
|
|
}
|