Core: Remove thema and kindsys dependencies (#84499)

* Move some thema code inside grafana

* Use new codegen instead of thema for core kinds

* Replace TS generator

* Use new generator for go types

* Remove thema from oapi generator

* Remove thema from generators

* Don't use kindsys/thema for core kinds

* Remove kindsys/thema from plugins

* Remove last thema related

* Remove most of cuectx and move utils_ts into codegen. It also deletes wire dependency

* Merge plugins generators

* Delete thema dependency 🎉

* Fix CODEOWNERS

* Fix package name

* Fix TS output names

* More path fixes

* Fix mod codeowners

* Use original plugin's name

* Remove kindsys dependency 🎉

* Modify oapi schema and create an apply function to fix elasticsearch errors

* cue.mod was deleted by mistake

* Fix TS panels

* sort imports

* Fixing elasticsearch output

* Downgrade oapi-codegen library

* Update output ts files

* More fixes

* Restore old elasticsearch generated file and skip its generation. Remove core imports into plugins

* More lint fixes

* Add codeowners

* restore embed.go file

* Fix embed.go
This commit is contained in:
Selene
2024-03-21 11:11:29 +01:00
committed by GitHub
parent 856e410480
commit 473898e47c
56 changed files with 1433 additions and 1631 deletions
+15 -35
View File
@@ -6,35 +6,22 @@ import (
"path/filepath"
"sort"
"github.com/grafana/thema"
"cuelang.org/go/cue/cuecontext"
)
type declParser struct {
rt *thema.Runtime
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,
func NewDeclParser(skip map[string]bool) *DeclParser {
return &DeclParser{
skip: skip,
}
}
// TODO convert this to be the new parser for Tree
func (psr *declParser) Parse(root fs.FS) ([]*PluginDecl, error) {
func (psr *DeclParser) Parse(root fs.FS) ([]*PluginDecl, error) {
ctx := cuecontext.New()
// TODO remove hardcoded tree structure assumption, work from root of provided fs
plugins, err := fs.Glob(root, "**/**/plugin.json")
if err != nil {
@@ -50,29 +37,22 @@ func (psr *declParser) Parse(root fs.FS) ([]*PluginDecl, error) {
}
dir, _ := fs.Sub(root, path)
pp, err := ParsePluginFS(dir, psr.rt)
pp, err := ParsePluginFS(ctx, dir, path)
if err != nil {
return nil, fmt.Errorf("parsing plugin failed for %s: %s", dir, err)
}
if len(pp.ComposableKinds) == 0 {
decls = append(decls, EmptyPluginDecl(path, pp.Properties))
if !pp.CueFile.Exists() {
continue
}
for slotName, kind := range pp.ComposableKinds {
if err != nil {
return nil, fmt.Errorf("parsing plugin failed for %s: %s", dir, err)
}
decls = append(decls, &PluginDecl{
SchemaInterface: schemaInterfaces[slotName],
Lineage: kind.Lineage(),
Imports: pp.CUEImports,
PluginMeta: pp.Properties,
PluginPath: path,
KindDecl: kind.Def(),
})
}
decls = append(decls, &PluginDecl{
SchemaInterface: pp.Variant,
CueFile: pp.CueFile,
Imports: pp.CUEImports,
PluginMeta: pp.Properties,
PluginPath: path,
})
}
sort.Slice(decls, func(i, j int) bool {