grafana/pkg/kindsys/kindmetas.go
sam boyer 3b3059c9ce
Kindsys: Unify plugins, pfs with kind framework (#61192)
* New pfs impl

* Reached codegen parity with old system

* Update all models.cue inputs

* Rename all models.cue files

* Remove unused prefixfs

* Changes Queries->DataQuery schema interface

* Recodegen

* All tests passing, nearly good now

* Add SchemaInterface to kindsys props

* Add pascal name deriver

* Relocate plugin cue files again

* Clarify use of injected fields

* Remove unnecessary aliasing

* Move DataQuery into mudball

* Allow forcing ExpandReferences on go type generation

* Move DataQuery def into kindsys, add generator to copy it to common

* Fix copy generator to replace package name correctly

* Fix duplicate type, test failure

* Fix linting issues
2023-01-20 09:41:35 +00:00

75 lines
2.4 KiB
Go

package kindsys
import "github.com/grafana/thema"
// CommonProperties contains the metadata common to all categories of kinds.
type CommonProperties struct {
Name string `json:"name"`
PluralName string `json:"pluralName"`
MachineName string `json:"machineName"`
PluralMachineName string `json:"pluralMachineName"`
LineageIsGroup bool `json:"lineageIsGroup"`
Maturity Maturity `json:"maturity"`
}
// CoreProperties represents the static properties in the declaration of a
// Core kind that are representable with basic Go types. This
// excludes Thema schemas.
//
// When a .cue Core declaration is loaded through the standard [LoadCoreKind],
// func, it is fully validated and populated according to all rules specified
// in CUE for Core kinds.
type CoreProperties struct {
CommonProperties
CurrentVersion thema.SyntacticVersion `json:"currentVersion"`
}
func (m CoreProperties) _private() {}
func (m CoreProperties) Common() CommonProperties {
return m.CommonProperties
}
// CustomProperties represents the static properties in the declaration of a
// Custom kind that are representable with basic Go types. This
// excludes Thema schemas.
type CustomProperties struct {
CommonProperties
CurrentVersion thema.SyntacticVersion `json:"currentVersion"`
}
func (m CustomProperties) _private() {}
func (m CustomProperties) Common() CommonProperties {
return m.CommonProperties
}
// ComposableProperties represents the static properties in the declaration of a
// Composable kind that are representable with basic Go types. This
// excludes Thema schemas.
type ComposableProperties struct {
CommonProperties
CurrentVersion thema.SyntacticVersion `json:"currentVersion"`
SchemaInterface string `json:"schemaInterface"`
}
func (m ComposableProperties) _private() {}
func (m ComposableProperties) Common() CommonProperties {
return m.CommonProperties
}
// SomeKindProperties is an interface type to abstract over the different kind
// property struct types: [CoreProperties], [CustomProperties],
// [ComposableProperties].
//
// It is the traditional interface counterpart to the generic type constraint
// KindProperties.
type SomeKindProperties interface {
_private()
Common() CommonProperties
}
// KindProperties is a type parameter that comprises the base possible set of
// kind metadata configurations.
type KindProperties interface {
CoreProperties | CustomProperties | ComposableProperties
}