mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* 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
32 lines
750 B
Cheetah
32 lines
750 B
Cheetah
{{ template "autogen_header.tmpl" .Header -}}
|
|
package corelist
|
|
|
|
import (
|
|
"fmt"
|
|
"io/fs"
|
|
"sync"
|
|
"github.com/grafana/grafana"
|
|
"github.com/grafana/grafana/pkg/plugins/pfs"
|
|
"github.com/grafana/thema"
|
|
)
|
|
|
|
func makeTreeOrPanic(path string, pkgname string, lib thema.Library) *pfs.Tree {
|
|
sub, err := fs.Sub(grafana.CueSchemaFS, path)
|
|
if err != nil {
|
|
panic("could not create fs sub to " + path)
|
|
}
|
|
tree, err := pfs.ParsePluginFS(sub, lib)
|
|
if err != nil {
|
|
panic(fmt.Sprintf("error parsing plugin metadata for %s: %s", pkgname, err))
|
|
}
|
|
return tree
|
|
}
|
|
|
|
func coreTreeList(lib thema.Library) pfs.TreeList{
|
|
return pfs.TreeList{
|
|
{{- range .Plugins }}
|
|
makeTreeOrPanic("{{ .Path }}", "{{ .PkgName }}", lib),
|
|
{{- end }}
|
|
}
|
|
}
|