mirror of
https://github.com/grafana/grafana.git
synced 2026-08-14 07:04:57 -05:00
plugindef: Move pluginmeta out of coremodels as standalone thema lineage (#56765)
* Get pluginmeta mostly moved over to pkg/plugins/plugindef * Remove dead func * Fix up pfs, use sync.Once in plugindef * Update to latest thema * Chase Endec->Codec conversion in Thema * Comments on slash header gen; use ToSlash * Also generate JSON schema for plugindef * Generate JSON Schema as well * Fix slot loading from kindsys cue decls * Remove unused vars * skip generating plugin.schema.json for now Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
This commit is contained in:
co-authored by
Marcus Efraimsson
parent
ff1afbb699
commit
78f0340031
@@ -0,0 +1,38 @@
|
||||
package plugindef
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"cuelang.org/go/cue/build"
|
||||
"github.com/grafana/grafana/pkg/cuectx"
|
||||
"github.com/grafana/thema"
|
||||
)
|
||||
|
||||
//go:generate go run gen.go
|
||||
|
||||
// PkgName is the name of the CUE package that Grafana will load when looking
|
||||
// for kind declarations by a Grafana plugin.
|
||||
const PkgName = "grafanaplugin"
|
||||
|
||||
func loadInstanceForplugindef() (*build.Instance, error) {
|
||||
return cuectx.LoadGrafanaInstance("pkg/plugins/plugindef", "", nil)
|
||||
}
|
||||
|
||||
var linonce sync.Once
|
||||
var pdlin thema.ConvergentLineage[*PluginDef]
|
||||
var pdlinerr error
|
||||
|
||||
// Lineage returns the [thema.ConvergentLineage] for plugindef, the canonical
|
||||
// specification for Grafana plugin.json files.
|
||||
//
|
||||
// Unless a custom thema.Runtime is specifically needed, prefer calling this with
|
||||
// nil, as a cached lineage will be returned.
|
||||
func Lineage(rt *thema.Runtime, opts ...thema.BindOption) (thema.ConvergentLineage[*PluginDef], error) {
|
||||
if len(opts) == 0 && (rt == nil || rt == cuectx.GrafanaThemaRuntime()) {
|
||||
linonce.Do(func() {
|
||||
pdlin, pdlinerr = doLineage(rt)
|
||||
})
|
||||
return pdlin, pdlinerr
|
||||
}
|
||||
return doLineage(rt, opts...)
|
||||
}
|
||||
Reference in New Issue
Block a user