pfs

package
v11.1.4-modfix Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

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

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

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

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 ErrNoRootFile = errors.New("no plugin.json at root of fs.fS")

ErrNoRootFile indicates that no root plugin.json file exists.

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

type Info struct {
	Version *string
}

type Metadata

type Metadata struct {
	Id      string
	Name    string
	Backend *bool
	Version *string
}

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

func ParsePluginFS(ctx *cue.Context, fsys fs.FS, dir string) (ParsedPlugin, error)

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 Permission struct {
	Action string  `json:"action"`
	Scope  *string `json:"scope,omitempty"`
}

type PluginDecl

type PluginDecl struct {
	SchemaInterface SchemaInterface
	CueFile         cue.Value
	Imports         []*ast.ImportSpec
	PluginPath      string
	PluginMeta      Metadata
}

type PluginDef

type PluginDef struct {
	Id      string
	Name    string
	Backend *bool
	Type    Type
	Info    Info
	IAM     IAM
}

func (PluginDef) Validate

func (pd PluginDef) Validate() error

type SchemaInterface

type SchemaInterface struct {
	Name    string
	IsGroup bool
}

type Type

type Type string
const (
	TypeApp            Type = "app"
	TypeDatasource     Type = "datasource"
	TypePanel          Type = "panel"
	TypeRenderer       Type = "renderer"
	TypeSecretsmanager Type = "secretsmanager"
)

Defines values for Type.

Jump to

Keyboard shortcuts

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