Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CUEFramework ¶
CUEFramework returns a cue.Value representing all the coremodel framework raw CUE files.
For low-level use in constructing other types and APIs, while still letting us declare all the frameworky CUE bits in a single package. Other types and subpackages make the constructs in this value easy to use.
The returned cue.Value is built from Grafana's standard central CUE context, ["github.com/grafana/grafana/pkg/cuectx".ProvideCueContext].
func CUEFrameworkWithContext ¶
CUEFrameworkWithContext is the same as CUEFramework, but allows control over the cue.Context that's used.
Prefer CUEFramework unless you understand cue.Context, and absolutely need this control.
func Mux ¶
func Mux(cm Interface, opts ...MuxOption) kernel.InputKernel
Mux takes a coremodel and returns a Thema version muxer that, given a byte slice containing any version of schema for that coremodel, will translate it to the Interface.CurrentSchema() version, and optionally decode it onto the Interface.GoType().
By default, JSON decoding will be used, and the filename given to any input bytes (shown in errors, which may be user-facing) will be "<name>.<encoding>", e.g. dashboard.json.
Types ¶
type Interface ¶
type Interface interface {
// Lineage should return the canonical Thema lineage for the coremodel.
Lineage() thema.Lineage
// CurrentSchema should return the schema of the version that the Grafana backend
// is currently written against. (While Grafana can accept data from all
// older versions of the Thema schema, backend Go code is written against a
// single version for simplicity)
CurrentSchema() thema.Schema
// GoType should return a pointer to the Go struct type that corresponds to
// the Current() schema.
GoType() interface{}
}
Interface is the primary coremodel interface that must be implemented by all Grafana coremodels. A coremodel is the foundational, canonical schema for some known-at-compile-time Grafana object.
Currently, all Coremodels are expressed as Thema lineages.
type MuxOption ¶
type MuxOption muxOption
A MuxOption defines options that may be specified only at initial construction of a Lineage via BindLineage.
func Filename ¶
Filename specifies the filename that is given to input bytes passing through the mux.
The filename has no impact on mux behavior, but is used in user-facing error output, such as schema validation failures. Thus, it is recommended to pick a name that will make sense in the context a user is expected to see the error.
type Slot ¶
type Slot struct {
// contains filtered or unexported fields
}
Slot represents one of Grafana's named Thema composition slot definitions.
func (Slot) ForPluginType ¶
ForPluginType indicates whether for this Slot, plugins of the given type may provide a slot implementation (first return value), and for those types that may, whether they must produce one (second return value).
Expected values here are those in the set of ["github.com/grafana/grafana/pkg/coremodel/pluginmeta".Type], though passing a string not in that set will harmlessly return {false, false}. That type is not used here to avoid import cycles.
Note that, at least for now, plugins are not required to provide any slot implementations, and do so by simply not containing a models.cue file. Consequently, the "must" return value here is best understood as, "IF a plugin provides a models.cue file, it MUST contain an implementation of this slot."
func (Slot) IsGroup ¶
IsGroup indicates whether the slot specifies a group lineage - one in which each top-level key represents a distinct schema for objects that are expected to exist in the wild, but objects corresponding to the root of the schema are not expected to exist.
func (Slot) MetaSchema ¶
MetaSchema returns the meta-schema that is the contract between coremodels that compose the Slot, and plugins that implement it.