schema: Migrate from scuemata to thema (#49805)
* Remove crufty scuemata bits Buhbye to: cue/ dir with old definitions, CI steps for checking unnecessary things, and the original dashboard scuemata file. * Remove grafana-cli cue subcommand * Remove old testdata * Don't swallow errors from codegen * Small nits and tweaks to cuectx package * WIP - refactor pluggen to use Thema Also consolidate the embed.FS in the repo root. * Finish halfway rename * Convert all panel models.cue to thema * Rewrite pluggen to use Thema * Remove pkg/schema, and trim command * Remove schemaloader service and usages Will be replaced by coremodel-centric hydrate/dehydrate system Soon™. * Remove schemaloader from wire * Remove hangover field on histogram models.cue * Fix lint errors, some vestiges of trim service * Remove unused cuetsify cli command
This commit is contained in:
+10
-4
@@ -17,8 +17,8 @@ import (
|
||||
"github.com/grafana/thema/load"
|
||||
)
|
||||
|
||||
var ctx *cue.Context = cuecontext.New()
|
||||
var lib thema.Library = thema.NewLibrary(ctx)
|
||||
var ctx = cuecontext.New()
|
||||
var lib = thema.NewLibrary(ctx)
|
||||
|
||||
// ProvideCUEContext is a wire service provider of a central cue.Context.
|
||||
func ProvideCUEContext() *cue.Context {
|
||||
@@ -82,6 +82,12 @@ func LoadGrafanaInstancesWithThema(
|
||||
return lin, nil
|
||||
}
|
||||
|
||||
// prefixWithGrafanaCUE constructs an fs.FS that merges the provided fs.FS with one
|
||||
// containing grafana's cue.mod at the root. The provided prefix should be the
|
||||
//
|
||||
// The returned fs.FS is suitable for passing to a CUE loader, such as
|
||||
// cuelang.org/cue/load.Instances or
|
||||
// github.com/grafana/thema/load.InstancesWithThema.
|
||||
func prefixWithGrafanaCUE(prefix string, inputfs fs.FS) (fs.FS, error) {
|
||||
m := fstest.MapFS{
|
||||
// fstest can recognize only forward slashes.
|
||||
@@ -89,7 +95,7 @@ func prefixWithGrafanaCUE(prefix string, inputfs fs.FS) (fs.FS, error) {
|
||||
}
|
||||
|
||||
prefix = filepath.FromSlash(prefix)
|
||||
err := fs.WalkDir(inputfs, ".", (func(path string, d fs.DirEntry, err error) error {
|
||||
err := fs.WalkDir(inputfs, ".", func(path string, d fs.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -111,7 +117,7 @@ func prefixWithGrafanaCUE(prefix string, inputfs fs.FS) (fs.FS, error) {
|
||||
// fstest can recognize only forward slashes.
|
||||
m[filepath.ToSlash(filepath.Join(prefix, path))] = &fstest.MapFile{Data: b}
|
||||
return nil
|
||||
}))
|
||||
})
|
||||
|
||||
return m, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user