plugins: Introduce generated, static core plugin registry (#54118)

* Refactor towards template/codegen framework

* Add templates for plugin gen

* Add Go codegen for plugins; overhaul framework, too

* Add new codegen output; assorted framework fixes

* Regenerate after merge

* Remove accidental commit file, update templates

* Export the pfs.Tree loader from plugin types

* Print details from cuetsy errors

* Generate loaders for all plugins and list in registry

* Use pfs_gen.go over lineage_gen.go

* Un-un-ignore main file

* Introduce simple List static registry for plugins

* Last tweaks to codegen

* remove unused tvars

* Ensure loop-local instances for both vars

* Generate pfs parsing in-place in registry

* Stop generating pfs_gen.go

* Move Tree into pfs, rename subdir

* Change package name to match dir

* Ignore gocyclo on HTTPServer.getNavTree
This commit is contained in:
sam boyer
2022-09-14 10:15:09 -04:00
committed by GitHub
parent c69a37f8c2
commit ced53a8dc2
36 changed files with 1114 additions and 324 deletions
+2 -2
View File
@@ -54,6 +54,6 @@ func provideBase(lib *thema.Library) *Base {
//
// The returned slice is sorted lexicographically by coremodel name. It should
// not be modified.
func (s *Base) All() []coremodel.Interface {
return s.all
func (b *Base) All() []coremodel.Interface {
return b.all
}
@@ -1,7 +1,8 @@
// This file is autogenerated. DO NOT EDIT.
//
// Generated by pkg/framework/coremodel/gen.go
// Run "make gen-cue" from repository root to regenerate.
//
// Run `make gen-cue` from repository root to regenerate.
package registry
@@ -37,14 +38,14 @@ var (
// Dashboard returns the dashboard coremodel. The return value is guaranteed to
// implement coremodel.Interface.
func (s *Base) Dashboard() *dashboard.Coremodel {
return s.dashboard
func (b *Base) Dashboard() *dashboard.Coremodel {
return b.dashboard
}
// Pluginmeta returns the pluginmeta coremodel. The return value is guaranteed to
// implement coremodel.Interface.
func (s *Base) Pluginmeta() *pluginmeta.Coremodel {
return s.pluginmeta
func (b *Base) Pluginmeta() *pluginmeta.Coremodel {
return b.pluginmeta
}
func doProvideBase(lib thema.Library) *Base {
+16
View File
@@ -42,6 +42,22 @@ func (s Slot) ForPluginType(plugintype string) (may, must bool) {
return
}
// IsGroup indicates whether the slot specifies a group lineage - one in which
// each top-level key represents a distinct schema for objects that are expected
// to exist in the wild, but objects corresponding to the root of the schema are not
// expected to exist.
func (s Slot) IsGroup() bool {
// TODO rely on first-class Thema properties for this, one they exist - https://github.com/grafana/thema/issues/62
switch s.name {
case "Panel", "DSOptions":
return true
case "Query":
return false
default:
panic("unreachable - unknown slot name " + s.name)
}
}
func AllSlots() map[string]*Slot {
fw := CUEFramework()
slots := make(map[string]*Slot)