Documentation ¶
Index ¶
Constants ¶
const PackageName = "grafanaplugin"
PackageName is the name of the CUE package that Grafana will load when looking for a Grafana plugin's kind declarations.
Variables ¶
var ErrDisallowedCUEImport = errors.New("CUE import is not allowed")
ErrDisallowedCUEImport indicates that a plugin's grafanaplugin cue package contains that are not on the allowlist.
var ErrEmptyFS = errors.New("provided fs.FS is empty")
ErrEmptyFS indicates that the fs.FS provided to ParsePluginFS was empty.
var ErrInvalidGrafanaPluginInstance = errors.New("grafanaplugin cue instance is invalid")
ErrInvalidGrafanaPluginInstance indicates a plugin's set of .cue grafanaplugin package files are invalid with respect to the GrafanaPlugin spec.
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 ErrNoRootFile = errors.New("no plugin.json at root of fs.fS")
ErrNoRootFile indicates that no root plugin.json file exists.
var PermittedCUEImports = codegen.PermittedCUEImports
PermittedCUEImports returns the list of import paths that may be used in a plugin's grafanaplugin cue package.
Functions ¶
This section is empty.
Types ¶
type DeclParser ¶
type DeclParser struct {
// contains filtered or unexported fields
}
func NewDeclParser ¶
func NewDeclParser(skip map[string]bool) *DeclParser
func (*DeclParser) Parse ¶
func (psr *DeclParser) Parse(root fs.FS) ([]*PluginDecl, error)
TODO convert this to be the new parser for Tree
type IAM ¶
type IAM struct {
Permissions []Permission `json:"permissions,omitempty"`
}
type ParsedPlugin ¶
type ParsedPlugin struct { // Properties contains the plugin's definition, as declared in plugin.json. Properties Metadata CueFile cue.Value Variant SchemaInterface // CUEImports lists the CUE import statements in the plugin's grafanaplugin CUE // package, if any. CUEImports []*ast.ImportSpec }
ParsedPlugin represents everything knowable about a single plugin from static analysis of its filesystem tree contents, as performed by ParsePluginFS.
Guarantees described in the below comments only exist for instances of this struct returned from ParsePluginFS.
func ParsePluginFS ¶
ParsePluginFS takes a virtual filesystem and checks that it contains a valid set of files that statically define a Grafana plugin.
The fsys must contain a plugin.json at the root, which must be valid according to the [plugindef] schema. If any .cue files exist in the grafanaplugin package, these will also be loaded and validated according to the GrafanaPlugin specification. This includes the validation of any custom or composable kinds and their contained lineages, via [thema.BindLineage].
This function parses exactly one plugin. It does not descend into subdirectories to search for additional plugin.json or .cue files.
type Permission ¶
type PluginDecl ¶
type PluginDecl struct { SchemaInterface SchemaInterface CueFile cue.Value Imports []*ast.ImportSpec PluginPath string PluginMeta Metadata }