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
This commit is contained in:
@@ -21,7 +21,7 @@ package kindsys
|
||||
// On the producer side, Grafana plugin authors may provide Thema lineages
|
||||
// within Composable kinds declared in .cue files adjacent to their
|
||||
// plugin.json, following a pattern (see
|
||||
// github.com/grafana/grafana/pkg/plugins/pfs.#GrafanaPlugin.composableKinds)
|
||||
// github.com/grafana/grafana/pkg/plugins/pfs.GrafanaPlugin.composableKinds)
|
||||
// corresponding to the name of the schema interface. Each such definition is
|
||||
// an answer to "what."
|
||||
//
|
||||
@@ -87,10 +87,14 @@ SchemaInterface: {
|
||||
group: bool | *true
|
||||
}
|
||||
|
||||
// alias the exported type because DataQuery is shadowed by the schema interface
|
||||
// name where we need to use the type
|
||||
let dq = DataQuery
|
||||
|
||||
// The canonical list of all Grafana schema interfaces.
|
||||
schemaInterfaces: [N=string]: SchemaInterface & { name: N }
|
||||
schemaInterfaces: {
|
||||
Panel: {
|
||||
PanelCfg: {
|
||||
interface: {
|
||||
// Defines plugin-specific options for a panel that should be persisted. Required,
|
||||
// though a panel without any options may specify an empty struct.
|
||||
@@ -109,22 +113,25 @@ schemaInterfaces: {
|
||||
// grouped b/c separate non-cross-referring elements always occur together in larger structure (panel)
|
||||
group: true
|
||||
}
|
||||
Query: {
|
||||
// The contract for the queries schema interface is itself a pattern:
|
||||
// Each of its top-level fields must be represent a distinct query type for
|
||||
// the datasource plugin. The queryType field acts as a discriminator, and
|
||||
// is constrained to be the same as the name of the top-level field declaring it.
|
||||
interface: [QT=string]: {
|
||||
queryType?: QT
|
||||
|
||||
// The DataQuery schema interface specifies how (datasource) plugins are expected to define
|
||||
// the shape of their queries.
|
||||
//
|
||||
// It is expected that plugins may support multiple logically distinct query types within
|
||||
// their single DataQuery composable kind. Implementations are generally free to model
|
||||
// this as they please, with understanding that Grafana systems will look to the queryType
|
||||
// field as a discriminator - each distinct value will be assumed, where possible, to
|
||||
// identify a distinct type of query supported by the plugin.
|
||||
DataQuery: {
|
||||
interface: {
|
||||
dq
|
||||
}
|
||||
|
||||
pluginTypes: ["datasource"]
|
||||
|
||||
// grouped b/c separate, non-cross-referring elements are actually themselves each impls of the concept
|
||||
// and it avoids us having to put more levels in the slot system (uggghhh)
|
||||
group: true
|
||||
group: false
|
||||
}
|
||||
DSOptions: {
|
||||
|
||||
DataSourceCfg: {
|
||||
interface: {
|
||||
// Normal datasource configuration options.
|
||||
Options: {}
|
||||
|
||||
Reference in New Issue
Block a user