pfs

package
v0.0.1-test Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2022 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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.

View Source
var ErrEmptyFS = errors.New("provided fs.FS is empty")

ErrEmptyFS indicates that the fs.FS provided to ParsePluginFS was empty.

View Source
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)
View Source
var ErrInvalidCUE = errors.New("CUE syntax error")

ErrInvalidCUE indicates that a plugin's model.cue file contained invalid CUE.

View Source
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].

View Source
var ErrInvalidRootFile = errors.New("plugin.json is invalid")

ErrInvalidRootFile indicates that the root plugin.json file is invalid.

View Source
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.

View Source
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

func ParsePluginFS(f fs.FS, lib thema.Library) (*Tree, error)

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) FS

func (t *Tree) FS() fs.FS

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.

type TreeList

type TreeList []*Tree

TreeList is a slice of validated plugin fs Trees with helper methods for filtering to particular subsets of its members.

func (TreeList) LineagesForSlot

func (tl TreeList) LineagesForSlot(slotname string) map[string]thema.Lineage

LineagesForSlot returns the set of plugin-defined lineages that implement a particular named Grafana slot (See ["github.com/grafana/grafana/pkg/framework/coremodel".Slot]).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL