Schemas: Refactor plugin's metadata (#83696)

* Remove kinds verification for kind-registry

* Read plugin's json information with json library instead of use thema binding

* Remove grafanaplugin unification

* Don't use kindsys for extract the slot name

* Fix IsGroup

* Remove all plugindef generation

* Refactor schema interfaces

* Pushed this change from a different branch by mistake...

* Create small plugin definition structure adding additional information for plugins registration

* Add some validation checks

* Delete unused code

* Fix imports lint
This commit is contained in:
Selene
2024-03-07 11:09:19 +01:00
committed by GitHub
parent beea7d1c2b
commit 1181141b40
29 changed files with 181 additions and 1401 deletions
+13 -3
View File
@@ -6,7 +6,6 @@ import (
"path/filepath"
"sort"
"github.com/grafana/kindsys"
"github.com/grafana/thema"
)
@@ -15,6 +14,18 @@ type declParser struct {
skip map[string]bool
}
// Extracted from kindsys repository
var schemaInterfaces = map[string]*SchemaInterface{
"PanelCfg": {
Name: "PanelCfg",
IsGroup: true,
},
"DataQuery": {
Name: "DataQuery",
IsGroup: false,
},
}
func NewDeclParser(rt *thema.Runtime, skip map[string]bool) *declParser {
return &declParser{
rt: rt,
@@ -50,12 +61,11 @@ func (psr *declParser) Parse(root fs.FS) ([]*PluginDecl, error) {
}
for slotName, kind := range pp.ComposableKinds {
slot, err := kindsys.FindSchemaInterface(slotName)
if err != nil {
return nil, fmt.Errorf("parsing plugin failed for %s: %s", dir, err)
}
decls = append(decls, &PluginDecl{
SchemaInterface: &slot,
SchemaInterface: schemaInterfaces[slotName],
Lineage: kind.Lineage(),
Imports: pp.CUEImports,
PluginMeta: pp.Properties,