Kindsys: Remove defs, Slot->SchemaInterface (#61069)
* kindsys: Remove defs, Slot->SchemaInterface * Remove excess file * Fix up tests * Regenerate kinds report * Final bits of cleanup * Stop complaining, linter * Update pkg/kindsys/kindcat_composable.cue Co-authored-by: Tania <yalyna.ts@gmail.com> Co-authored-by: Tania <yalyna.ts@gmail.com>
This commit is contained in:
@@ -17,7 +17,7 @@ type ManyToMany codejen.ManyToMany[*DeclForGen]
|
||||
|
||||
// ForGen is a codejen input transformer that converts a pure kindsys.SomeDecl into
|
||||
// a DeclForGen by binding its contained lineage.
|
||||
func ForGen(rt *thema.Runtime, decl *kindsys.SomeDecl) (*DeclForGen, error) {
|
||||
func ForGen(rt *thema.Runtime, decl kindsys.SomeDecl) (*DeclForGen, error) {
|
||||
lin, err := decl.BindKindLineage(rt)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -32,7 +32,7 @@ func ForGen(rt *thema.Runtime, decl *kindsys.SomeDecl) (*DeclForGen, error) {
|
||||
// DeclForGen wraps [kindsys.SomeDecl] to provide trivial caching of
|
||||
// the lineage declared by the kind (nil for raw kinds).
|
||||
type DeclForGen struct {
|
||||
*kindsys.SomeDecl
|
||||
kindsys.SomeDecl
|
||||
lin thema.Lineage
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ func (gen *genBaseRegistry) JennyName() string {
|
||||
func (gen *genBaseRegistry) Generate(decls ...*DeclForGen) (*codejen.File, error) {
|
||||
buf := new(bytes.Buffer)
|
||||
if err := tmpls.Lookup("kind_registry.tmpl").Execute(buf, tvars_kind_registry{
|
||||
NumStructured: len(decls),
|
||||
PackageName: filepath.Base(gen.path),
|
||||
KindPackagePrefix: filepath.ToSlash(filepath.Join("github.com/grafana/grafana", gen.kindrelroot)),
|
||||
Kinds: decls,
|
||||
|
||||
@@ -15,9 +15,9 @@ import (
|
||||
// all generated kinds.
|
||||
//
|
||||
// This generator only has output for core structured kinds.
|
||||
func CoreKindJenny(gokindsdir string, cfg *CoreStructuredKindGeneratorConfig) OneToOne {
|
||||
func CoreKindJenny(gokindsdir string, cfg *CoreKindJennyConfig) OneToOne {
|
||||
if cfg == nil {
|
||||
cfg = new(CoreStructuredKindGeneratorConfig)
|
||||
cfg = new(CoreKindJennyConfig)
|
||||
}
|
||||
if cfg.GenDirName == nil {
|
||||
cfg.GenDirName = func(decl *DeclForGen) string {
|
||||
@@ -31,8 +31,8 @@ func CoreKindJenny(gokindsdir string, cfg *CoreStructuredKindGeneratorConfig) On
|
||||
}
|
||||
}
|
||||
|
||||
// CoreStructuredKindGeneratorConfig holds configuration options for [CoreKindJenny].
|
||||
type CoreStructuredKindGeneratorConfig struct {
|
||||
// CoreKindJennyConfig holds configuration options for [CoreKindJenny].
|
||||
type CoreKindJennyConfig struct {
|
||||
// GenDirName returns the name of the directory in which the file should be
|
||||
// generated. Defaults to DeclForGen.Lineage().Name() if nil.
|
||||
GenDirName func(*DeclForGen) string
|
||||
@@ -40,7 +40,7 @@ type CoreStructuredKindGeneratorConfig struct {
|
||||
|
||||
type coreKindJenny struct {
|
||||
gokindsdir string
|
||||
cfg *CoreStructuredKindGeneratorConfig
|
||||
cfg *CoreKindJennyConfig
|
||||
}
|
||||
|
||||
var _ OneToOne = &coreKindJenny{}
|
||||
|
||||
@@ -38,7 +38,6 @@ type (
|
||||
}
|
||||
tvars_kind_registry struct {
|
||||
// Header tvars_autogen_header
|
||||
NumStructured int
|
||||
PackageName string
|
||||
KindPackagePrefix string
|
||||
Kinds []*DeclForGen
|
||||
|
||||
@@ -30,7 +30,7 @@ func NewKind(rt *thema.Runtime, opts ...thema.BindOption) (*Kind, error) {
|
||||
return nil, err
|
||||
}
|
||||
k := &Kind{
|
||||
decl: *decl,
|
||||
decl: decl,
|
||||
}
|
||||
|
||||
lin, err := decl.Some().BindKindLineage(rt, opts...)
|
||||
@@ -91,9 +91,8 @@ func (k *Kind) Maturity() kindsys.Maturity {
|
||||
|
||||
// Decl returns the [kindsys.Decl] containing both CUE and Go representations of the
|
||||
// {{ .Properties.MachineName }} declaration in .cue files.
|
||||
func (k *Kind) Decl() *kindsys.Decl[kindsys.CoreProperties] {
|
||||
d := k.decl
|
||||
return &d
|
||||
func (k *Kind) Decl() kindsys.Decl[kindsys.CoreProperties] {
|
||||
return k.decl
|
||||
}
|
||||
|
||||
// Props returns a [kindsys.SomeKindProps], with underlying type [kindsys.CoreProperties],
|
||||
|
||||
Reference in New Issue
Block a user