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:
@@ -37,40 +37,11 @@ func NewBase(rt *thema.Runtime) *Base {
|
||||
return doNewBase(rt)
|
||||
}
|
||||
|
||||
// All returns a slice of the [kindsys.Interface] instances corresponding to all
|
||||
// core raw and structured kinds.
|
||||
// All returns a slice of [kindsys.Core] containing all core Grafana kinds.
|
||||
//
|
||||
// The returned slice is sorted lexicographically by kind machine name.
|
||||
func (b *Base) All() []kindsys.Interface {
|
||||
ret := make([]kindsys.Interface, len(b.all))
|
||||
func (b *Base) All() []kindsys.Core {
|
||||
ret := make([]kindsys.Core, len(b.all))
|
||||
copy(ret, b.all)
|
||||
return ret
|
||||
}
|
||||
|
||||
// AllRaw returns a slice of the [kindsys.Raw] instances for all raw kinds.
|
||||
//
|
||||
// The returned slice is sorted lexicographically by kind machine name.
|
||||
func (b *Base) AllRaw() []kindsys.Raw {
|
||||
ret := make([]kindsys.Raw, 0, b.numRaw)
|
||||
for _, k := range b.all {
|
||||
if rk, is := k.(kindsys.Raw); is {
|
||||
ret = append(ret, rk)
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
// AllStructured returns a slice of the [kindsys.Structured] instances for
|
||||
// all core structured kinds.
|
||||
//
|
||||
// The returned slice is sorted lexicographically by kind machine name.
|
||||
func (b *Base) AllStructured() []kindsys.Structured {
|
||||
ret := make([]kindsys.Structured, 0, b.numStructured)
|
||||
for _, k := range b.all {
|
||||
if rk, is := k.(kindsys.Structured); is {
|
||||
ret = append(ret, rk)
|
||||
}
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
|
||||
"github.com/grafana/grafana/pkg/kinds/dashboard"
|
||||
"github.com/grafana/grafana/pkg/kinds/playlist"
|
||||
"github.com/grafana/grafana/pkg/kinds/svg"
|
||||
"github.com/grafana/grafana/pkg/kinds/team"
|
||||
"github.com/grafana/grafana/pkg/kindsys"
|
||||
"github.com/grafana/thema"
|
||||
@@ -31,20 +30,17 @@ 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
|
||||
dashboard *dashboard.Kind
|
||||
playlist *playlist.Kind
|
||||
svg *svg.Kind
|
||||
team *team.Kind
|
||||
all []kindsys.Core
|
||||
dashboard *dashboard.Kind
|
||||
playlist *playlist.Kind
|
||||
team *team.Kind
|
||||
}
|
||||
|
||||
// type guards
|
||||
var (
|
||||
_ kindsys.Structured = &dashboard.Kind{}
|
||||
_ kindsys.Structured = &playlist.Kind{}
|
||||
_ kindsys.Raw = &svg.Kind{}
|
||||
_ kindsys.Structured = &team.Kind{}
|
||||
_ kindsys.Core = &dashboard.Kind{}
|
||||
_ kindsys.Core = &playlist.Kind{}
|
||||
_ kindsys.Core = &team.Kind{}
|
||||
)
|
||||
|
||||
// Dashboard returns the [kindsys.Interface] implementation for the dashboard kind.
|
||||
@@ -57,11 +53,6 @@ func (b *Base) Playlist() *playlist.Kind {
|
||||
return b.playlist
|
||||
}
|
||||
|
||||
// SVG returns the [kindsys.Interface] implementation for the svg kind.
|
||||
func (b *Base) SVG() *svg.Kind {
|
||||
return b.svg
|
||||
}
|
||||
|
||||
// Team returns the [kindsys.Interface] implementation for the team kind.
|
||||
func (b *Base) Team() *team.Kind {
|
||||
return b.team
|
||||
@@ -69,10 +60,7 @@ func (b *Base) Team() *team.Kind {
|
||||
|
||||
func doNewBase(rt *thema.Runtime) *Base {
|
||||
var err error
|
||||
reg := &Base{
|
||||
numRaw: 1,
|
||||
numStructured: 3,
|
||||
}
|
||||
reg := &Base{}
|
||||
|
||||
reg.dashboard, err = dashboard.NewKind(rt)
|
||||
if err != nil {
|
||||
@@ -86,12 +74,6 @@ func doNewBase(rt *thema.Runtime) *Base {
|
||||
}
|
||||
reg.all = append(reg.all, reg.playlist)
|
||||
|
||||
reg.svg, err = svg.NewKind()
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("error while initializing the svg Kind: %s", err))
|
||||
}
|
||||
reg.all = append(reg.all, reg.svg)
|
||||
|
||||
reg.team, err = team.NewKind(rt)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("error while initializing the team Kind: %s", err))
|
||||
|
||||
Reference in New Issue
Block a user