grafana/pkg/codegen/tmpl.go
Selene 5c7849417b
Schemas: Replace registry generation and github workflow (#83490)
* 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
2024-03-13 18:05:21 +02:00

59 lines
1018 B
Go

package codegen
import (
"embed"
"strings"
"text/template"
"time"
"github.com/grafana/codejen"
)
// All the parsed templates in the tmpl subdirectory
var tmpls *template.Template
func init() {
base := template.New("codegen").Funcs(template.FuncMap{
"now": time.Now,
"ToLower": strings.ToLower,
})
tmpls = template.Must(base.ParseFS(tmplFS, "tmpl/*.tmpl"))
}
//go:embed tmpl/*.tmpl
var tmplFS embed.FS
// The following group of types, beginning with tvars_*, all contain the set
// of variables expected by the corresponding named template file under tmpl/
type (
tvars_gen_header struct {
MainGenerator string
Using []codejen.NamedJenny
From string
Leader string
}
tvars_resource struct {
PackageName string
KindName string
Version string
}
tvars_metadata struct {
PackageName string
}
tvars_status struct {
PackageName string
}
tvars_registry struct {
Schemas []Schema
}
Schema struct {
Name string
FilePath string
}
)