coremodels: Update to latest Thema with generics (#56602)

* Update thema to latest

* Deal with s/Library/*Runtime/

* Commit new, working results of codegen
This commit is contained in:
sam boyer
2022-10-11 04:45:07 -04:00
committed by GitHub
parent 668cb25b82
commit e5a6547a94
26 changed files with 171 additions and 247 deletions

View File

@@ -1018,8 +1018,8 @@ var currentVersion = thema.SV(0, 0)
// The lineage is the canonical specification of the current dashboard schema,
// all prior schema versions, and the mappings that allow migration between
// schema versions.
func Lineage(lib thema.Library, opts ...thema.BindOption) (thema.Lineage, error) {
return cuectx.LoadGrafanaInstancesWithThema(filepath.Join("pkg", "coremodel", "dashboard"), cueFS, lib, opts...)
func Lineage(rt *thema.Runtime, opts ...thema.BindOption) (thema.Lineage, error) {
return cuectx.LoadGrafanaInstancesWithThema(filepath.Join("pkg", "coremodel", "dashboard"), cueFS, rt, opts...)
}
var _ thema.LineageFactory = Lineage
@@ -1052,8 +1052,8 @@ func (c *Coremodel) GoType() interface{} {
// Note that this function does not cache, and initially loading a Thema lineage
// can be expensive. As such, the Grafana backend should prefer to access this
// coremodel through a registry (pkg/framework/coremodel/registry), which does cache.
func New(lib thema.Library) (*Coremodel, error) {
lin, err := Lineage(lib)
func New(rt *thema.Runtime) (*Coremodel, error) {
lin, err := Lineage(rt)
if err != nil {
return nil, err
}

View File

@@ -22,7 +22,7 @@ func TestDevenvDashboardValidity(t *testing.T) {
m, err := themaTestableDashboards(os.DirFS(path))
require.NoError(t, err)
cm, err := dashboard.New(cuectx.ProvideThemaLibrary())
cm, err := dashboard.New(cuectx.GrafanaThemaRuntime())
require.NoError(t, err)
for path, b := range m {

View File

@@ -90,8 +90,8 @@ var currentVersion = thema.SV(0, 0)
// The lineage is the canonical specification of the current playlist schema,
// all prior schema versions, and the mappings that allow migration between
// schema versions.
func Lineage(lib thema.Library, opts ...thema.BindOption) (thema.Lineage, error) {
return cuectx.LoadGrafanaInstancesWithThema(filepath.Join("pkg", "coremodel", "playlist"), cueFS, lib, opts...)
func Lineage(rt *thema.Runtime, opts ...thema.BindOption) (thema.Lineage, error) {
return cuectx.LoadGrafanaInstancesWithThema(filepath.Join("pkg", "coremodel", "playlist"), cueFS, rt, opts...)
}
var _ thema.LineageFactory = Lineage
@@ -124,8 +124,8 @@ func (c *Coremodel) GoType() interface{} {
// Note that this function does not cache, and initially loading a Thema lineage
// can be expensive. As such, the Grafana backend should prefer to access this
// coremodel through a registry (pkg/framework/coremodel/registry), which does cache.
func New(lib thema.Library) (*Coremodel, error) {
lin, err := Lineage(lib)
func New(rt *thema.Runtime) (*Coremodel, error) {
lin, err := Lineage(rt)
if err != nil {
return nil, err
}

View File

@@ -560,8 +560,8 @@ var currentVersion = thema.SV(0, 0)
// The lineage is the canonical specification of the current pluginmeta schema,
// all prior schema versions, and the mappings that allow migration between
// schema versions.
func Lineage(lib thema.Library, opts ...thema.BindOption) (thema.Lineage, error) {
return cuectx.LoadGrafanaInstancesWithThema(filepath.Join("pkg", "coremodel", "pluginmeta"), cueFS, lib, opts...)
func Lineage(rt *thema.Runtime, opts ...thema.BindOption) (thema.Lineage, error) {
return cuectx.LoadGrafanaInstancesWithThema(filepath.Join("pkg", "coremodel", "pluginmeta"), cueFS, rt, opts...)
}
var _ thema.LineageFactory = Lineage
@@ -594,8 +594,8 @@ func (c *Coremodel) GoType() interface{} {
// Note that this function does not cache, and initially loading a Thema lineage
// can be expensive. As such, the Grafana backend should prefer to access this
// coremodel through a registry (pkg/framework/coremodel/registry), which does cache.
func New(lib thema.Library) (*Coremodel, error) {
lin, err := Lineage(lib)
func New(rt *thema.Runtime) (*Coremodel, error) {
lin, err := Lineage(rt)
if err != nil {
return nil, err
}