mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 18:34:52 -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
66 lines
1.4 KiB
Go
66 lines
1.4 KiB
Go
package codegen
|
|
|
|
import (
|
|
"embed"
|
|
"text/template"
|
|
"time"
|
|
)
|
|
|
|
// All the parsed templates in the tmpl subdirectory
|
|
var tmpls *template.Template
|
|
|
|
func init() {
|
|
base := template.New("codegen").Funcs(template.FuncMap{
|
|
"now": time.Now,
|
|
})
|
|
tmpls = template.Must(base.ParseFS(tmplFS, "tmpl/*.tmpl"))
|
|
}
|
|
|
|
//go:embed tmpl/*.tmpl
|
|
var tmplFS embed.FS
|
|
|
|
// The following group of types, beginning with tvars_*, all contain the set
|
|
// of variables expected by the corresponding named template file under tmpl/
|
|
type (
|
|
tvars_autogen_header struct {
|
|
GeneratorPath string
|
|
LineagePath string
|
|
LineageCUEPath string
|
|
GenLicense bool
|
|
}
|
|
tvars_coremodel_registry struct {
|
|
Header tvars_autogen_header
|
|
Coremodels []tplVars
|
|
}
|
|
tvars_coremodel_imports struct {
|
|
PackageName string
|
|
}
|
|
tvars_plugin_lineage_binding struct {
|
|
SlotName string
|
|
LatestMajv, LatestMinv uint
|
|
}
|
|
tvars_plugin_lineage_file struct {
|
|
PackageName string
|
|
PluginID string
|
|
PluginType string
|
|
HasModels bool
|
|
RootCUE bool
|
|
SlotImpls []tvars_plugin_lineage_binding
|
|
Header tvars_autogen_header
|
|
}
|
|
tvars_cuetsy_multi struct {
|
|
Header tvars_autogen_header
|
|
Imports []*tsImport
|
|
Sections []tsSection
|
|
}
|
|
tvars_plugin_registry struct {
|
|
Header tvars_autogen_header
|
|
Plugins []struct {
|
|
PkgName string
|
|
Path string
|
|
ImportPath string
|
|
NoAlias bool
|
|
}
|
|
}
|
|
)
|