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

View File

@@ -1,8 +1,10 @@
// This file is autogenerated. DO NOT EDIT.
//
// Run "make gen-cue" from repository root to regenerate.
// Generated by pkg/framework/coremodel/gen.go
//
// Derived from the Thema lineage at pkg/coremodel/pluginmeta
// Derived from the Thema lineage declared in pkg/coremodel/pluginmeta/coremodel.cue
//
// Run `make gen-cue` from repository root to regenerate.
package pluginmeta
@@ -15,7 +17,7 @@ import (
"github.com/grafana/thema"
)
// Defines values for PluginmetaCategory.
// Defines values for Category.
const (
CategoryCloud Category = "cloud"
@@ -32,7 +34,7 @@ const (
CategoryTsdb Category = "tsdb"
)
// Defines values for PluginmetaType.
// Defines values for Type.
const (
TypeApp Type = "app"
@@ -45,7 +47,7 @@ const (
TypeSecretsmanager Type = "secretsmanager"
)
// Defines values for PluginmetaDependencyType.
// Defines values for DependencyType.
const (
DependencyTypeApp DependencyType = "app"
@@ -54,7 +56,7 @@ const (
DependencyTypePanel DependencyType = "panel"
)
// Defines values for PluginmetaIncludeRole.
// Defines values for IncludeRole.
const (
IncludeRoleAdmin IncludeRole = "Admin"
@@ -63,7 +65,7 @@ const (
IncludeRoleViewer IncludeRole = "Viewer"
)
// Defines values for PluginmetaIncludeType.
// Defines values for IncludeType.
const (
IncludeTypeApp IncludeType = "app"
@@ -80,7 +82,7 @@ const (
IncludeTypeSecretsmanager IncludeType = "secretsmanager"
)
// Defines values for PluginmetaReleaseState.
// Defines values for ReleaseState.
const (
ReleaseStateAlpha ReleaseState = "alpha"
@@ -91,7 +93,7 @@ const (
ReleaseStateStable ReleaseState = "stable"
)
// Pluginmeta defines model for pluginmeta.
// Model is the Go representation of a pluginmeta.
//
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
@@ -287,7 +289,7 @@ type Category string
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type Type string
// PluginmetaBuildInfo defines model for pluginmeta.BuildInfo.
// BuildInfo is the Go representation of a pluginmeta.BuildInfo.
//
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
@@ -307,7 +309,7 @@ type BuildInfo struct {
Time *int64 `json:"time,omitempty"`
}
// PluginmetaDependencies defines model for pluginmeta.Dependencies.
// Dependencies is the Go representation of a pluginmeta.Dependencies.
//
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
@@ -338,7 +340,7 @@ type Dependency struct {
Version string `json:"version"`
}
// PluginmetaDependencyType defines model for PluginmetaDependency.Type.
// DependencyType is the Go representation of a Dependency.Type.
//
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
@@ -383,13 +385,13 @@ type Include struct {
Uid *string `json:"uid,omitempty"`
}
// PluginmetaIncludeRole defines model for PluginmetaInclude.Role.
// IncludeRole is the Go representation of a Include.Role.
//
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
type IncludeRole string
// PluginmetaIncludeType defines model for PluginmetaInclude.Type.
// IncludeType is the Go representation of a Include.Type.
//
// THIS TYPE IS INTENDED FOR INTERNAL USE BY THE GRAFANA BACKEND, AND IS SUBJECT TO BREAKING CHANGES.
// Equivalent Go types at stable import paths are provided in https://github.com/grafana/grok.
@@ -546,7 +548,11 @@ type URLParam struct {
//go:embed coremodel.cue
var cueFS embed.FS
// codegen ensures that this is always the latest Thema schema version
// The current version of the coremodel schema, as declared in coremodel.cue.
// This version determines what schema version is returned from [Coremodel.CurrentSchema],
// and which schema version is used for code generation within the grafana/grafana repository.
//
// The code generator ensures that this is always the latest Thema schema version.
var currentVersion = thema.SV(0, 0)
// Lineage returns the Thema lineage representing a Grafana pluginmeta.