mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 16:15:42 -06:00
* 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>
39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
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...)
|
|
}
|