mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 05:46:28 +08:00
Kindsys: Replace DefForGen
with kindsys.Kind
(#62642)
* Kindsys: Replace DeclForGen with kindsys.Kind DeclForGen was always unnecessary - it just wasn't obvious on initial implementation, when we were focused on generating unique types for each core kind. This removes it, considerably simplifying interactions with kindsys - virtually everything now just relies on kindsys.Kind and its derived interfaces. * Removed unused jenny * Rename params in jennies
This commit is contained in:
@ -5,6 +5,7 @@ import (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/grafana/codejen"
|
||||
"github.com/grafana/grafana/pkg/kindsys"
|
||||
)
|
||||
|
||||
// LatestJenny returns a jenny that runs another jenny for only the latest
|
||||
@ -31,17 +32,17 @@ func (j *latestj) JennyName() string {
|
||||
return "LatestJenny"
|
||||
}
|
||||
|
||||
func (j *latestj) Generate(def *DefForGen) (*codejen.File, error) {
|
||||
comm := def.Properties.Common()
|
||||
func (j *latestj) Generate(kind kindsys.Kind) (*codejen.File, error) {
|
||||
comm := kind.Props().Common()
|
||||
sfg := SchemaForGen{
|
||||
Name: comm.Name,
|
||||
Schema: def.Lineage().Latest(),
|
||||
Schema: kind.Lineage().Latest(),
|
||||
IsGroup: comm.LineageIsGroup,
|
||||
}
|
||||
|
||||
f, err := j.inner.Generate(sfg)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%s jenny failed on %s schema for %s: %w", j.inner.JennyName(), sfg.Schema.Version(), def.Properties.Common().Name, err)
|
||||
return nil, fmt.Errorf("%s jenny failed on %s schema for %s: %w", j.inner.JennyName(), sfg.Schema.Version(), kind.Props().Common().Name, err)
|
||||
}
|
||||
if f == nil || !f.Exists() {
|
||||
return nil, nil
|
||||
|
Reference in New Issue
Block a user