mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Kindsys: Remove Raw kind category (#60992)
* Remove Raw references * Remove more raws * Re-generate files * Remove raw folder from veneer * Fix import * Fix lint * Bring back raw folder in grafana-schema * Another lint * Remove use of "Structured" word in kinds * Delete unused function and remove some structured words * Bunch more removals of structured name Co-authored-by: sam boyer <sdboyer@grafana.com>
This commit is contained in:
@@ -3,5 +3,5 @@ package kind
|
||||
import "github.com/grafana/grafana/pkg/kindsys"
|
||||
|
||||
// In each child directory, the set of .cue files with 'package kind'
|
||||
// must be an instance of kindsys.#Raw - a declaration of a raw kind.
|
||||
kindsys.#Raw
|
||||
// must be an instance of kindsys.#Core - a declaration of a core kind.
|
||||
kindsys.#Core
|
||||
39
kinds/gen.go
39
kinds/gen.go
@@ -28,7 +28,7 @@ func main() {
|
||||
}
|
||||
|
||||
// Core kinds composite code generator. Produces all generated code in
|
||||
// grafana/grafana that derives from raw and structured core kinds.
|
||||
// grafana/grafana that derives from core kinds.
|
||||
coreKindsGen := codejen.JennyListWithNamer(func(decl *codegen.DeclForGen) string {
|
||||
return decl.Properties.Common().MachineName
|
||||
})
|
||||
@@ -36,8 +36,7 @@ func main() {
|
||||
// All the jennies that comprise the core kinds generator pipeline
|
||||
coreKindsGen.Append(
|
||||
codegen.LatestJenny(kindsys.GoCoreKindParentPath, codegen.GoTypesJenny{}),
|
||||
codegen.CoreStructuredKindJenny(kindsys.GoCoreKindParentPath, nil),
|
||||
codegen.RawKindJenny(kindsys.GoCoreKindParentPath, nil),
|
||||
codegen.CoreKindJenny(kindsys.GoCoreKindParentPath, nil),
|
||||
codegen.BaseCoreRegistryJenny(filepath.Join("pkg", "registry", "corekind"), kindsys.GoCoreKindParentPath),
|
||||
codegen.LatestMajorsOrXJenny(kindsys.TSCoreKindParentPath, codegen.TSTypesJenny{}),
|
||||
codegen.TSVeneerIndexJenny(filepath.Join("packages", "grafana-schema", "src")),
|
||||
@@ -55,15 +54,14 @@ func main() {
|
||||
rt := cuectx.GrafanaThemaRuntime()
|
||||
var all []*codegen.DeclForGen
|
||||
|
||||
// structured kinddirs first
|
||||
f := os.DirFS(filepath.Join(groot, kindsys.CoreStructuredDeclParentPath))
|
||||
kinddirs := elsedie(fs.ReadDir(f, "."))("error reading structured fs root directory")
|
||||
f := os.DirFS(filepath.Join(groot, kindsys.CoreDeclParentPath))
|
||||
kinddirs := elsedie(fs.ReadDir(f, "."))("error reading core kind fs root directory")
|
||||
for _, ent := range kinddirs {
|
||||
if !ent.IsDir() {
|
||||
continue
|
||||
}
|
||||
rel := filepath.Join(kindsys.CoreStructuredDeclParentPath, ent.Name())
|
||||
decl, err := kindsys.LoadCoreKind[kindsys.CoreStructuredProperties](rel, rt.Context(), nil)
|
||||
rel := filepath.Join(kindsys.CoreDeclParentPath, ent.Name())
|
||||
decl, err := kindsys.LoadCoreKind(rel, rt.Context(), nil)
|
||||
if err != nil {
|
||||
die(fmt.Errorf("%s is not a valid kind: %s", rel, errors.Details(err, nil)))
|
||||
}
|
||||
@@ -74,25 +72,6 @@ func main() {
|
||||
all = append(all, elsedie(codegen.ForGen(rt, decl.Some()))(rel))
|
||||
}
|
||||
|
||||
// now raw kinddirs
|
||||
f = os.DirFS(filepath.Join(groot, kindsys.RawDeclParentPath))
|
||||
kinddirs = elsedie(fs.ReadDir(f, "."))("error reading raw fs root directory")
|
||||
for _, ent := range kinddirs {
|
||||
if !ent.IsDir() {
|
||||
continue
|
||||
}
|
||||
rel := filepath.Join(kindsys.RawDeclParentPath, ent.Name())
|
||||
decl, err := kindsys.LoadCoreKind[kindsys.RawProperties](rel, rt.Context(), nil)
|
||||
if err != nil {
|
||||
die(fmt.Errorf("%s is not a valid kind: %s", rel, errors.Details(err, nil)))
|
||||
}
|
||||
if decl.Properties.MachineName != ent.Name() {
|
||||
die(fmt.Errorf("%s: kind's machine name (%s) must equal parent dir name (%s)", rel, decl.Properties.Name, ent.Name()))
|
||||
}
|
||||
dfg, _ := codegen.ForGen(nil, decl.Some())
|
||||
all = append(all, dfg)
|
||||
}
|
||||
|
||||
sort.Slice(all, func(i, j int) bool {
|
||||
return nameFor(all[i].Properties) < nameFor(all[j].Properties)
|
||||
})
|
||||
@@ -113,11 +92,9 @@ func main() {
|
||||
|
||||
func nameFor(m kindsys.SomeKindProperties) string {
|
||||
switch x := m.(type) {
|
||||
case kindsys.RawProperties:
|
||||
case kindsys.CoreProperties:
|
||||
return x.Name
|
||||
case kindsys.CoreStructuredProperties:
|
||||
return x.Name
|
||||
case kindsys.CustomStructuredProperties:
|
||||
case kindsys.CustomProperties:
|
||||
return x.Name
|
||||
case kindsys.ComposableProperties:
|
||||
return x.Name
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
package kind
|
||||
|
||||
name: "SVG"
|
||||
extensions: ["svg"]
|
||||
@@ -1,8 +0,0 @@
|
||||
package kind
|
||||
|
||||
import "github.com/grafana/grafana/pkg/kindsys"
|
||||
|
||||
// In each child directory, the set of .cue files with 'package kind'
|
||||
// must be an instance of kindsys.#CoreStructured - a declaration of a
|
||||
// structured kind.
|
||||
kindsys.#CoreStructured
|
||||
Reference in New Issue
Block a user