Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrDisallowedCUEImport = errors.New("CUE import is not allowed")
ErrDisallowedCUEImport indicates that a plugin's models.cue file imports a CUE package that is not on the whitelist for safe imports.
var ErrEmptyFS = errors.New("provided fs.FS is empty")
ErrEmptyFS indicates that the fs.FS provided to ParsePluginFS was empty.
var ErrImplementedSlots = errors.New("slot implementation not allowed for this plugin type")
ErrImplementedSlots indicates that a plugin has implemented the wrong set of slots for its type in models.cue. Either:
- A slot is implemented that is not allowed for its type (e.g. datasource plugin implements Panel)
- A required slot for its type is not implemented (e.g. panel plugin does not implemented Panel)
var ErrInvalidCUE = errors.New("CUE syntax error")
ErrInvalidCUE indicates that a plugin's model.cue file contained invalid CUE.
var ErrInvalidLineage = errors.New("invalid lineage")
ErrInvalidLineage indicates that the plugin contains an invalid lineage declaration, according to Thema's validation rules in ["github.com/grafana/thema".BindLineage].
var ErrInvalidRootFile = errors.New("plugin.json is invalid")
ErrInvalidRootFile indicates that the root plugin.json file is invalid.
var ErrLineageNameMismatch = errors.New("lineage name not the same as plugin id")
ErrLineageNameMismatch indicates a plugin slot lineage name did not match the id of the plugin.
var ErrNoRootFile = errors.New("no plugin.json at root of fs.fS")
ErrNoRootFile indicates that no root plugin.json file exists.
Functions ¶
func PermittedCUEImports ¶
func PermittedCUEImports() []string
PermittedCUEImports returns the list of packages that may be imported in a plugin models.cue file.
Types ¶
type PluginInfo ¶
type PluginInfo struct {
// contains filtered or unexported fields
}
PluginInfo represents everything knowable about a single plugin from static analysis of its filesystem tree contents.
func (PluginInfo) CUEImports ¶
func (pi PluginInfo) CUEImports() []*ast.ImportSpec
CUEImports lists the CUE import statements in the plugin's models.cue file, if any.
func (PluginInfo) Meta ¶
func (pi PluginInfo) Meta() pluginmeta.Model
Meta returns the metadata declared in the plugin's plugin.json file.
func (PluginInfo) SlotImplementations ¶
func (pi PluginInfo) SlotImplementations() map[string]thema.Lineage
SlotImplementations returns a map of the plugin's Thema lineages that implement particular slots, keyed by the name of the slot.
Returns an empty map if the plugin has not implemented any slots.
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree represents the contents of a plugin filesystem tree.
func ParsePluginFS ¶
ParsePluginFS takes an fs.FS and checks that it represents exactly one valid plugin fs tree, with the fs.FS root as the root of the tree.
It does not descend into subdirectories to search for additional plugin.json files. TODO no descent is ok for core plugins, but won't cut it in general
func (*Tree) RootPlugin ¶
func (t *Tree) RootPlugin() PluginInfo
func (*Tree) SubPlugins ¶
func (t *Tree) SubPlugins() map[string]PluginInfo
SubPlugins returned a map of the PluginInfos for subplugins within the tree, if any, keyed by subpath.