coremodels: Update to latest Thema with generics (#56602)
* Update thema to latest * Deal with s/Library/*Runtime/ * Commit new, working results of codegen
This commit is contained in:
@@ -19,14 +19,14 @@ var ptree *pfs.Tree
|
||||
var plugFS embed.FS
|
||||
|
||||
// PluginTree returns the plugin tree representing the statically analyzable contents of the {{ .PluginID }} plugin.
|
||||
func PluginTree(lib *thema.Library) *pfs.Tree {
|
||||
func PluginTree(rt *thema.Runtime) *pfs.Tree {
|
||||
var err error
|
||||
if lib == nil {
|
||||
if rt == nil || rt == cuectx.GrafanaThemaRuntime() {
|
||||
parseOnce.Do(func() {
|
||||
ptree, err = pfs.ParsePluginFS(plugFS, cuectx.ProvideThemaLibrary())
|
||||
ptree, err = pfs.ParsePluginFS(plugFS, cuectx.GrafanaThemaRuntime())
|
||||
})
|
||||
} else {
|
||||
ptree, err = pfs.ParsePluginFS(plugFS, cuectx.ProvideThemaLibrary())
|
||||
ptree, err = pfs.ParsePluginFS(plugFS, rt)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
@@ -40,8 +40,8 @@ func PluginTree(lib *thema.Library) *pfs.Tree {
|
||||
{{ $pluginfo := . }}{{ range $slot := .SlotImpls }}
|
||||
// {{ .SlotName }}Lineage returns the Thema lineage for the {{ $pluginfo.PluginID }} {{ $pluginfo.PluginType }} plugin's
|
||||
// {{ .SlotName }} ["github.com/grafana/grafana/pkg/framework/coremodel".Slot] implementation.
|
||||
func {{ .SlotName }}Lineage(lib *thema.Library, opts ...thema.BindOption) (thema.Lineage, error) {
|
||||
t := PluginTree(lib)
|
||||
func {{ .SlotName }}Lineage(rt *thema.Runtime, opts ...thema.BindOption) (thema.Lineage, error) {
|
||||
t := PluginTree(rt)
|
||||
lin, has := t.RootPlugin().SlotImplementations()["{{ .SlotName }}"]
|
||||
if !has {
|
||||
panic("unreachable: lineage for {{ .SlotName }} does not exist, but code is only generated for existing lineages")
|
||||
|
||||
Reference in New Issue
Block a user