mirror of
https://github.com/grafana/grafana.git
synced 2025-07-30 01:12:09 +08:00
80 lines
1.7 KiB
Go
80 lines
1.7 KiB
Go
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
|
//
|
|
// Generated by:
|
|
// kinds/gen.go
|
|
// Using jennies:
|
|
// CoreRegistryJenny
|
|
//
|
|
// Run 'make gen-cue' from repository root to regenerate.
|
|
|
|
package schemas
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"runtime"
|
|
|
|
"cuelang.org/go/cue"
|
|
"cuelang.org/go/cue/cuecontext"
|
|
)
|
|
|
|
type CoreKind struct {
|
|
Name string
|
|
CueFile cue.Value
|
|
}
|
|
|
|
func GetCoreKinds() ([]CoreKind, error) {
|
|
ctx := cuecontext.New()
|
|
kinds := make([]CoreKind, 0)
|
|
|
|
_, caller, _, _ := runtime.Caller(0)
|
|
root := filepath.Join(caller, "../../../..")
|
|
|
|
dashboardCue, err := loadCueFile(ctx, filepath.Join(root, "./kinds/dashboard/dashboard_kind.cue"))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
kinds = append(kinds, CoreKind{
|
|
Name: "dashboard",
|
|
CueFile: dashboardCue,
|
|
})
|
|
|
|
librarypanelCue, err := loadCueFile(ctx, filepath.Join(root, "./kinds/librarypanel/librarypanel_kind.cue"))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
kinds = append(kinds, CoreKind{
|
|
Name: "librarypanel",
|
|
CueFile: librarypanelCue,
|
|
})
|
|
|
|
preferencesCue, err := loadCueFile(ctx, filepath.Join(root, "./kinds/preferences/preferences_kind.cue"))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
kinds = append(kinds, CoreKind{
|
|
Name: "preferences",
|
|
CueFile: preferencesCue,
|
|
})
|
|
|
|
publicdashboardCue, err := loadCueFile(ctx, filepath.Join(root, "./kinds/publicdashboard/public_dashboard_kind.cue"))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
kinds = append(kinds, CoreKind{
|
|
Name: "publicdashboard",
|
|
CueFile: publicdashboardCue,
|
|
})
|
|
|
|
return kinds, nil
|
|
}
|
|
|
|
func loadCueFile(ctx *cue.Context, path string) (cue.Value, error) {
|
|
cueFile, err := os.ReadFile(path)
|
|
if err != nil {
|
|
return cue.Value{}, err
|
|
}
|
|
|
|
return ctx.CompileBytes(cueFile), nil
|
|
}
|