mirror of
https://github.com/grafana/grafana.git
synced 2025-02-10 23:55:47 -06:00
* Create small registries for core and composable kinds * Update workflow with new registries * Fix imports in plugin schemas and deleted old registry generation files * Remove verification and maturity * Modify registries and add missing composable information to make schemas in kind-registry work * Add missing aliases * Remove unused templates * Remove kinds verification * Format generated code * Add gen header * Delete unused code and clean path in composable template * Delete kind-registry loader * Delete unused code * Update License link * Update codeowners path * Sort imports * More cleanup * Remove verify-kinds.yml from codeowners * Fix lint * Update composable_kidns * Fix cue extension * Restore verify-kinds to avoid to push outdated kind's registry * Fix composable format * Restore code owners for verify-kinds * Remove verify check
47 lines
934 B
Cheetah
47 lines
934 B
Cheetah
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, "../../../..")
|
|
|
|
{{- range .Schemas }}
|
|
|
|
{{ .Name }}Cue, err := loadCueFile(ctx, filepath.Join(root, "{{ .FilePath }}"))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
kinds = append(kinds, CoreKind{
|
|
Name: "{{ .Name }}",
|
|
CueFile: {{ .Name }}Cue,
|
|
})
|
|
{{- end }}
|
|
|
|
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
|
|
}
|