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:
@@ -10,22 +10,22 @@ import (
|
||||
// directory containing the .cue files in which this kind is declared. Necessary
|
||||
// for runtime errors related to the declaration and/or lineage to provide
|
||||
// a real path to the correct .cue file.
|
||||
const rootrel string = "kinds/structured/{{ .Properties.MachineName }}"
|
||||
const rootrel string = "kinds/{{ .Properties.MachineName }}"
|
||||
|
||||
// TODO standard generated docs
|
||||
type Kind struct {
|
||||
lin thema.ConvergentLineage[*{{ .Properties.Name }}]
|
||||
jcodec vmux.Codec
|
||||
valmux vmux.ValueMux[*{{ .Properties.Name }}]
|
||||
decl kindsys.Decl[kindsys.CoreStructuredProperties]
|
||||
decl kindsys.Decl[kindsys.CoreProperties]
|
||||
}
|
||||
|
||||
// type guard
|
||||
var _ kindsys.Structured = &Kind{}
|
||||
var _ kindsys.Core = &Kind{}
|
||||
|
||||
// TODO standard generated docs
|
||||
func NewKind(rt *thema.Runtime, opts ...thema.BindOption) (*Kind, error) {
|
||||
decl, err := kindsys.LoadCoreKind[kindsys.CoreStructuredProperties](rootrel, rt.Context(), nil)
|
||||
decl, err := kindsys.LoadCoreKind(rootrel, rt.Context(), nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -91,12 +91,12 @@ 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.CoreStructuredProperties] {
|
||||
func (k *Kind) Decl() *kindsys.Decl[kindsys.CoreProperties] {
|
||||
d := k.decl
|
||||
return &d
|
||||
}
|
||||
|
||||
// Props returns a [kindsys.SomeKindProps], with underlying type [kindsys.CoreStructuredProperties],
|
||||
// Props returns a [kindsys.SomeKindProps], with underlying type [kindsys.CoreProperties],
|
||||
// representing the static properties declared in the {{ .Properties.MachineName }} kind.
|
||||
//
|
||||
// This method is identical to calling Decl().Props. It is provided to satisfy [kindsys.Interface].
|
||||
@@ -1,57 +0,0 @@
|
||||
package {{ .Properties.MachineName }}
|
||||
|
||||
import (
|
||||
"github.com/grafana/grafana/pkg/kindsys"
|
||||
"github.com/grafana/thema"
|
||||
"github.com/grafana/thema/vmux"
|
||||
)
|
||||
|
||||
// TODO standard generated docs
|
||||
type Kind struct {
|
||||
decl kindsys.Decl[kindsys.RawProperties]
|
||||
}
|
||||
|
||||
// type guard
|
||||
var _ kindsys.Raw = &Kind{}
|
||||
|
||||
// TODO standard generated docs
|
||||
func NewKind() (*Kind, error) {
|
||||
decl, err := kindsys.LoadCoreKind[kindsys.RawProperties]("kinds/raw/{{ .Properties.MachineName }}", nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Kind{
|
||||
decl: *decl,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// TODO standard generated docs
|
||||
func (k *Kind) Name() string {
|
||||
return "{{ .Properties.Name }}"
|
||||
}
|
||||
|
||||
// TODO standard generated docs
|
||||
func (k *Kind) MachineName() string {
|
||||
return "{{ .Properties.MachineName }}"
|
||||
}
|
||||
|
||||
// TODO standard generated docs
|
||||
func (k *Kind) Maturity() kindsys.Maturity {
|
||||
return k.decl.Properties.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.RawProperties] {
|
||||
d := k.decl
|
||||
return &d
|
||||
}
|
||||
|
||||
// Props returns a [kindsys.SomeKindProps], with underlying type [kindsys.RawProperties],
|
||||
// representing the static properties declared in the {{ .Properties.MachineName }} kind.
|
||||
//
|
||||
// This method is identical to calling Decl().Props. It is provided to satisfy [kindsys.Interface].
|
||||
func (k *Kind) Props() kindsys.SomeKindProperties {
|
||||
return k.decl.Properties
|
||||
}
|
||||
@@ -22,8 +22,7 @@ import (
|
||||
// Prefer All*() methods when performing operations generically across all kinds.
|
||||
// For example, a validation HTTP middleware for any kind-schematized object type.
|
||||
type Base struct {
|
||||
all []kindsys.Interface
|
||||
numRaw, numStructured int
|
||||
all []kindsys.Core
|
||||
{{- range .Kinds }}
|
||||
{{ .Properties.MachineName }} *{{ .Properties.MachineName }}.Kind{{end}}
|
||||
}
|
||||
@@ -31,7 +30,7 @@ type Base struct {
|
||||
// type guards
|
||||
var (
|
||||
{{- range .Kinds }}
|
||||
_ kindsys.{{ if .IsRaw }}Raw{{ else }}Structured{{ end }} = &{{ .Properties.MachineName }}.Kind{}{{end}}
|
||||
_ kindsys.Core = &{{ .Properties.MachineName }}.Kind{}{{end}}
|
||||
)
|
||||
|
||||
{{range .Kinds }}
|
||||
@@ -43,13 +42,10 @@ func (b *Base) {{ .Properties.Name }}() *{{ .Properties.MachineName }}.Kind {
|
||||
|
||||
func doNewBase(rt *thema.Runtime) *Base {
|
||||
var err error
|
||||
reg := &Base{
|
||||
numRaw: {{ .NumRaw }},
|
||||
numStructured: {{ .NumStructured }},
|
||||
}
|
||||
reg := &Base{}
|
||||
|
||||
{{range .Kinds }}
|
||||
reg.{{ .Properties.MachineName }}, err = {{ .Properties.MachineName }}.NewKind({{ if .IsCoreStructured }}rt{{ end }})
|
||||
reg.{{ .Properties.MachineName }}, err = {{ .Properties.MachineName }}.NewKind(rt)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("error while initializing the {{ .Properties.MachineName }} Kind: %s", err))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user