Documentation ¶
Index ¶
- Constants
- Variables
- type AppDTO
- type BackendFactoryProvider
- type BuildInfo
- type Class
- type Client
- type ClientMiddleware
- type ClientMiddlewareFunc
- type CompatOpts
- type DataSourceDTO
- type Dependencies
- type Dependency
- type DuplicateError
- type Error
- type ErrorCode
- type ErrorResolver
- type FS
- type FSRemover
- type FeatureToggles
- type File
- type FileStore
- type FoundBundle
- type FoundPlugin
- type Header
- type Includes
- type Info
- type InfoLink
- type Installer
- type JSONData
- type JWTTokenAuth
- type KeyRetriever
- type KeyStore
- type Licensing
- type LocalFS
- type LocalFile
- type Logos
- type NotFoundError
- type PanelDTO
- type Permission
- type Plugin
- func (p *Plugin) CallResource(ctx context.Context, req *backend.CallResourceRequest, ...) error
- func (p *Plugin) CheckHealth(ctx context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error)
- func (p *Plugin) Client() (PluginClient, bool)
- func (p *Plugin) CollectMetrics(ctx context.Context, req *backend.CollectMetricsRequest) (*backend.CollectMetricsResult, error)
- func (p *Plugin) Decommission() error
- func (p *Plugin) ExecutablePath() string
- func (p *Plugin) Exited() bool
- func (p *Plugin) File(name string) (fs.File, error)
- func (p *Plugin) IsApp() bool
- func (p *Plugin) IsBundledPlugin() bool
- func (p *Plugin) IsCorePlugin() bool
- func (p *Plugin) IsDecommissioned() bool
- func (p *Plugin) IsExternalPlugin() bool
- func (p *Plugin) IsManaged() bool
- func (p *Plugin) IsRenderer() bool
- func (p *Plugin) IsSecretsManager() bool
- func (p *Plugin) Logger() log.Logger
- func (p *Plugin) PluginID() string
- func (p *Plugin) PublishStream(ctx context.Context, req *backend.PublishStreamRequest) (*backend.PublishStreamResponse, error)
- func (p *Plugin) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error)
- func (p *Plugin) RegisterClient(c backendplugin.Plugin)
- func (p *Plugin) RunStream(ctx context.Context, req *backend.RunStreamRequest, ...) error
- func (p *Plugin) SetLogger(l log.Logger)
- func (p *Plugin) Start(ctx context.Context) error
- func (p *Plugin) StaticRoute() *StaticRoute
- func (p *Plugin) Stop(ctx context.Context) error
- func (p *Plugin) SubscribeStream(ctx context.Context, req *backend.SubscribeStreamRequest) (*backend.SubscribeStreamResponse, error)
- func (p *Plugin) Target() backendplugin.Target
- func (p *Plugin) ToDTO() PluginDTO
- type PluginClient
- type PluginDTO
- type PluginLoaderAuthorizer
- type PluginMetaDTO
- type PluginSource
- type QueryCachingConfig
- type ReleaseState
- type RendererManager
- type Role
- type RoleRegistration
- type RoleRegistry
- type Route
- type Screenshots
- type SecretsPluginManager
- type Signature
- type SignatureCalculator
- type SignatureError
- type SignatureStatus
- type SignatureType
- type StaticFS
- type StaticRoute
- type StaticRouteResolver
- type Store
- type Type
- type URLParam
- type UpdateInfo
Constants ¶
const (
TypeDashboard = "dashboard"
)
Variables ¶
var ( // ErrPluginNotRegistered error returned when a plugin is not registered. ErrPluginNotRegistered = errutil.NewBase(errutil.StatusNotFound, "plugin.notRegistered") // ErrHealthCheckFailed error returned when a plugin health check failed. ErrHealthCheckFailed = errutil.NewBase(errutil.StatusInternal, "plugin.failedHealthCheck") ErrPluginUnavailable = errutil.NewBase(errutil.StatusInternal, "plugin.unavailable") // ErrMethodNotImplemented error returned when a plugin method is not implemented. ErrMethodNotImplemented = errutil.NewBase(errutil.StatusNotImplemented, "plugin.notImplemented") // ErrPluginDownstreamError error returned when a plugin method is not implemented. ErrPluginDownstreamError = errutil.NewBase(errutil.StatusInternal, "plugin.downstreamError", errutil.WithPublicMessage("An error occurred within the plugin")) )
var ( ErrInstallCorePlugin = errors.New("cannot install a Core plugin") ErrUninstallCorePlugin = errors.New("cannot uninstall a Core plugin") ErrPluginNotInstalled = errors.New("plugin is not installed") )
var ( ErrFileNotExist = errors.New("file does not exist") ErrPluginFileRead = errors.New("file could not be read") ErrUninstallInvalidPluginDir = errors.New("cannot recognize as plugin folder") ErrInvalidPluginJSON = errors.New("did not find valid type or id properties in plugin.json") )
var PluginTypes = []Type{ TypeDataSource, TypePanel, TypeApp, TypeRenderer, TypeSecretsManager, }
Functions ¶
This section is empty.
Types ¶
type BackendFactoryProvider ¶
type BackendFactoryProvider interface {
BackendFactory(ctx context.Context, p *Plugin) backendplugin.PluginFactoryFunc
}
BackendFactoryProvider provides a backend factory for a provided plugin.
type Client ¶
type Client interface { backend.QueryDataHandler backend.CheckHealthHandler backend.StreamHandler backend.CallResourceHandler backend.CollectMetricsHandler }
Client is used to communicate with backend plugin implementations.
type ClientMiddleware ¶
type ClientMiddleware interface { // CreateClientMiddleware creates a new client middleware. CreateClientMiddleware(next Client) Client }
ClientMiddleware is an interface representing the ability to create a middleware that implements the Client interface.
type ClientMiddlewareFunc ¶
The ClientMiddlewareFunc type is an adapter to allow the use of ordinary functions as ClientMiddleware's. If f is a function with the appropriate signature, ClientMiddlewareFunc(f) is a ClientMiddleware that calls f.
func (ClientMiddlewareFunc) CreateClientMiddleware ¶
func (fn ClientMiddlewareFunc) CreateClientMiddleware(next Client) Client
CreateClientMiddleware implements the ClientMiddleware interface.
type CompatOpts ¶
type CompatOpts struct {
// contains filtered or unexported fields
}
func NewCompatOpts ¶
func NewCompatOpts(grafanaVersion, os, arch string) CompatOpts
func NewSystemCompatOpts ¶
func NewSystemCompatOpts(os, arch string) CompatOpts
func (CompatOpts) Arch ¶
func (co CompatOpts) Arch() string
func (CompatOpts) GrafanaVersion ¶
func (co CompatOpts) GrafanaVersion() string
func (CompatOpts) OS ¶
func (co CompatOpts) OS() string
type DataSourceDTO ¶
type DataSourceDTO struct { ID int64 `json:"id,omitempty"` UID string `json:"uid,omitempty"` Type string `json:"type"` Name string `json:"name"` PluginMeta *PluginMetaDTO `json:"meta"` URL string `json:"url,omitempty"` IsDefault bool `json:"isDefault"` Access string `json:"access,omitempty"` Preload bool `json:"preload"` Module string `json:"module,omitempty"` JSONData map[string]interface{} `json:"jsonData"` ReadOnly bool `json:"readOnly"` AngularDetected bool `json:"angularDetected"` BasicAuth string `json:"basicAuth,omitempty"` WithCredentials bool `json:"withCredentials,omitempty"` // This is populated by an Enterprise hook CachingConfig QueryCachingConfig `json:"cachingConfig,omitempty"` // InfluxDB Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` // InfluxDB + Elasticsearch Database string `json:"database,omitempty"` // Prometheus DirectURL string `json:"directUrl,omitempty"` }
type Dependencies ¶
type Dependencies struct { GrafanaDependency string `json:"grafanaDependency"` GrafanaVersion string `json:"grafanaVersion"` Plugins []Dependency `json:"plugins"` }
type Dependency ¶
type DuplicateError ¶
type DuplicateError struct {
PluginID string
}
func (DuplicateError) Error ¶
func (e DuplicateError) Error() string
func (DuplicateError) Is ¶
func (e DuplicateError) Is(err error) bool
type ErrorResolver ¶
type FS ¶
func NewFakeFS ¶
func NewFakeFS() FS
NewFakeFS returns a new FS that always returns ErrFileNotExist when trying to Open() and empty Files().
func NewInMemoryFS ¶
NewInMemoryFS returns a new FS with the specified files and content. The provided value is a map from file name (keys) to file content (values).
type FeatureToggles ¶
type FoundBundle ¶
type FoundBundle struct { Primary FoundPlugin Children []*FoundPlugin }
type FoundPlugin ¶
type Header ¶
Header describes an HTTP header that is forwarded with the proxied request for a plugin route
type Includes ¶
type Includes struct { Name string `json:"name"` Path string `json:"path"` Type string `json:"type"` Component string `json:"component"` Role org.RoleType `json:"role"` Action string `json:"action,omitempty"` Slug string `json:"slug"` Icon string `json:"icon"` UID string `json:"uid"` ID string `json:"-"` }
func (Includes) DashboardURLPath ¶
func (Includes) RequiresRBACAction ¶
type JSONData ¶
type JSONData struct { // Common settings ID string `json:"id"` Type Type `json:"type"` Name string `json:"name"` Alias string `json:"alias,omitempty"` Info Info `json:"info"` Dependencies Dependencies `json:"dependencies"` Includes []*Includes `json:"includes"` State ReleaseState `json:"state,omitempty"` Category string `json:"category"` HideFromList bool `json:"hideFromList,omitempty"` Preload bool `json:"preload"` Backend bool `json:"backend"` Routes []*Route `json:"routes"` // AccessControl settings Roles []RoleRegistration `json:"roles,omitempty"` // Panel settings SkipDataQuery bool `json:"skipDataQuery"` // App settings AutoEnabled bool `json:"autoEnabled"` // Datasource settings Annotations bool `json:"annotations"` Metrics bool `json:"metrics"` Alerting bool `json:"alerting"` Explore bool `json:"explore"` Table bool `json:"tables"` Logs bool `json:"logs"` Tracing bool `json:"tracing"` QueryOptions map[string]bool `json:"queryOptions,omitempty"` BuiltIn bool `json:"builtIn,omitempty"` Mixed bool `json:"mixed,omitempty"` Streaming bool `json:"streaming"` SDK bool `json:"sdk,omitempty"` // Backend (Datasource + Renderer + SecretsManager) Executable string `json:"executable,omitempty"` // Oauth App Service Registration ExternalServiceRegistration *plugindef.ExternalServiceRegistration `json:"externalServiceRegistration,omitempty"` }
JSONData represents the plugin's plugin.json
func (JSONData) DashboardIncludes ¶
type JWTTokenAuth ¶
type JWTTokenAuth struct { Url string `json:"url"` Scopes []string `json:"scopes"` Params map[string]string `json:"params"` }
JWTTokenAuth struct is both for normal Token Auth and JWT Token Auth with an uploaded JWT file.
type KeyRetriever ¶
type KeyStore ¶
type KeyStore interface { Get(ctx context.Context, key string) (string, bool, error) Set(ctx context.Context, key string, value string) error Del(ctx context.Context, key string) error ListKeys(ctx context.Context) ([]string, error) GetLastUpdated(ctx context.Context) (*time.Time, error) SetLastUpdated(ctx context.Context) error }
type LocalFS ¶
type LocalFS struct {
// contains filtered or unexported fields
}
LocalFS is a plugins.FS that allows accessing files on the local file system.
func NewLocalFS ¶
NewLocalFS returns a new LocalFS that can access any file in the specified base path on the filesystem. basePath must use os-specific path separator for Open() to work properly.
func (LocalFS) Base ¶
Base returns the base path for the LocalFS. The returned string uses os-specific path separator.
func (LocalFS) Files ¶
Files returns a slice of all the relative file paths on the LocalFS. The returned strings can be passed to Open() to open those files. The returned strings use os-specific path separator.
func (LocalFS) Open ¶
Open opens the specified file on the local filesystem. The provided name must be a relative file name that uses os-specific path separators. The function returns the corresponding fs.File for accessing the file on the local filesystem. If a nil error is returned, the caller should take care of calling Close() the returned fs.File. If the file does not exist, ErrFileNotExist is returned.
type LocalFile ¶
type LocalFile struct {
// contains filtered or unexported fields
}
LocalFile implements a fs.File for accessing the local filesystem.
func (*LocalFile) Close ¶
Close closes the file. If the file was never open, nil is returned. If the file is already closed, an error is returned.
func (*LocalFile) Read ¶
Read reads up to len(b) bytes from the File and stores them in b. It returns the number of bytes read and any error encountered. At end of file, Read returns 0, io.EOF. If the file is already open, it is opened again, without closing it first. The file is not closed at the end of the read operation. If a non-nil error is returned, it must be manually closed by the caller by calling Close().
type NotFoundError ¶
type NotFoundError struct {
PluginID string
}
func (NotFoundError) Error ¶
func (e NotFoundError) Error() string
type PanelDTO ¶
type PanelDTO struct { ID string `json:"id"` Name string `json:"name"` Alias string `json:"alias,omitempty"` Info Info `json:"info"` HideFromList bool `json:"hideFromList"` Sort int `json:"sort"` SkipDataQuery bool `json:"skipDataQuery"` ReleaseState string `json:"state"` BaseURL string `json:"baseUrl"` Signature string `json:"signature"` Module string `json:"module"` AngularDetected bool `json:"angularDetected"` }
type Permission ¶
type Plugin ¶
type Plugin struct { JSONData FS FS Class Class // App fields IncludedInAppID string Pinned bool // Signature fields Signature SignatureStatus SignatureType SignatureType SignatureOrg string Parent *Plugin Children []*Plugin SignatureError *SignatureError // SystemJS fields Module string BaseURL string AngularDetected bool ExternalService *oauth.ExternalService Renderer pluginextensionv2.RendererPlugin SecretsManager secretsmanagerplugin.SecretsManagerPlugin // This will be moved to plugin.json when we have general support in gcom Alias string `json:"alias,omitempty"` // contains filtered or unexported fields }
func (*Plugin) CallResource ¶
func (p *Plugin) CallResource(ctx context.Context, req *backend.CallResourceRequest, sender backend.CallResourceResponseSender) error
func (*Plugin) CheckHealth ¶
func (p *Plugin) CheckHealth(ctx context.Context, req *backend.CheckHealthRequest) (*backend.CheckHealthResult, error)
func (*Plugin) Client ¶
func (p *Plugin) Client() (PluginClient, bool)
func (*Plugin) CollectMetrics ¶
func (p *Plugin) CollectMetrics(ctx context.Context, req *backend.CollectMetricsRequest) (*backend.CollectMetricsResult, error)
func (*Plugin) Decommission ¶
func (*Plugin) ExecutablePath ¶
func (*Plugin) IsBundledPlugin ¶
func (*Plugin) IsCorePlugin ¶
func (*Plugin) IsDecommissioned ¶
func (*Plugin) IsExternalPlugin ¶
func (*Plugin) IsRenderer ¶
func (*Plugin) IsSecretsManager ¶
func (*Plugin) PublishStream ¶
func (p *Plugin) PublishStream(ctx context.Context, req *backend.PublishStreamRequest) (*backend.PublishStreamResponse, error)
func (*Plugin) QueryData ¶
func (p *Plugin) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error)
func (*Plugin) RegisterClient ¶
func (p *Plugin) RegisterClient(c backendplugin.Plugin)
func (*Plugin) RunStream ¶
func (p *Plugin) RunStream(ctx context.Context, req *backend.RunStreamRequest, sender *backend.StreamSender) error
func (*Plugin) StaticRoute ¶
func (p *Plugin) StaticRoute() *StaticRoute
func (*Plugin) SubscribeStream ¶
func (p *Plugin) SubscribeStream(ctx context.Context, req *backend.SubscribeStreamRequest) (*backend.SubscribeStreamResponse, error)
func (*Plugin) Target ¶
func (p *Plugin) Target() backendplugin.Target
type PluginClient ¶
type PluginClient interface { backend.QueryDataHandler backend.CollectMetricsHandler backend.CheckHealthHandler backend.CallResourceHandler backend.StreamHandler }
type PluginDTO ¶
type PluginDTO struct { JSONData Class Class // App fields IncludedInAppID string Pinned bool // Signature fields Signature SignatureStatus SignatureType SignatureType SignatureOrg string SignatureError *SignatureError // SystemJS fields Module string BaseURL string AngularDetected bool // This will be moved to plugin.json when we have general support in gcom Alias string `json:"alias,omitempty"` // contains filtered or unexported fields }
func (PluginDTO) IsCorePlugin ¶
func (PluginDTO) SupportsStreaming ¶
type PluginLoaderAuthorizer ¶
type PluginMetaDTO ¶
type PluginMetaDTO struct { JSONData Signature SignatureStatus `json:"signature"` Module string `json:"module"` BaseURL string `json:"baseUrl"` }
type PluginSource ¶
type QueryCachingConfig ¶
type RendererManager ¶
type Role ¶
type Role struct { Name string `json:"name"` Description string `json:"description"` Permissions []Permission `json:"permissions"` }
Role is the model for Role in RBAC.
type RoleRegistration ¶
RoleRegistration stores a role and its assignments to basic roles (Viewer, Editor, Admin, Grafana Admin)
type RoleRegistry ¶
type RoleRegistry interface {
DeclarePluginRoles(ctx context.Context, ID, name string, registrations []RoleRegistration) error
}
RoleRegistry handles the plugin RBAC roles and their assignments
type Route ¶
type Route struct { Path string `json:"path"` Method string `json:"method"` ReqRole org.RoleType `json:"reqRole"` URL string `json:"url"` URLParams []URLParam `json:"urlParams"` Headers []Header `json:"headers"` AuthType string `json:"authType"` TokenAuth *JWTTokenAuth `json:"tokenAuth"` JwtTokenAuth *JWTTokenAuth `json:"jwtTokenAuth"` Body json.RawMessage `json:"body"` }
Route describes a plugin route that is defined in the plugin.json file for a plugin.
type Screenshots ¶
type SecretsPluginManager ¶
type Signature ¶
type Signature struct { Status SignatureStatus Type SignatureType SigningOrg string }
type SignatureCalculator ¶
type SignatureCalculator interface {
Calculate(ctx context.Context, src PluginSource, plugin FoundPlugin) (Signature, error)
}
type SignatureError ¶
type SignatureError struct { PluginID string `json:"pluginId"` SignatureStatus SignatureStatus `json:"status"` }
func (SignatureError) AsErrorCode ¶
func (e SignatureError) AsErrorCode() ErrorCode
func (SignatureError) Error ¶
func (e SignatureError) Error() string
type SignatureStatus ¶
type SignatureStatus string
const ( SignatureStatusInternal SignatureStatus = "internal" // core plugin, no signature SignatureStatusValid SignatureStatus = "valid" // signed and accurate MANIFEST SignatureStatusInvalid SignatureStatus = "invalid" // invalid signature SignatureStatusModified SignatureStatus = "modified" // valid signature, but content mismatch SignatureStatusUnsigned SignatureStatus = "unsigned" // no MANIFEST file )
func (SignatureStatus) IsInternal ¶
func (ss SignatureStatus) IsInternal() bool
func (SignatureStatus) IsValid ¶
func (ss SignatureStatus) IsValid() bool
type SignatureType ¶
type SignatureType string
const ( SignatureTypeGrafana SignatureType = "grafana" SignatureTypeCommercial SignatureType = "commercial" SignatureTypeCommunity SignatureType = "community" SignatureTypePrivate SignatureType = "private" SignatureTypePrivateGlob SignatureType = "private-glob" )
func (SignatureType) IsValid ¶
func (s SignatureType) IsValid() bool
type StaticFS ¶
type StaticFS struct { FS // contains filtered or unexported fields }
StaticFS wraps an FS and allows accessing only the files in the allowList. This is a more secure implementation of a FS suitable for production environments. The keys of the allow list must be in the same format used by the underlying FS' Open() method.
func NewStaticFS ¶
NewStaticFS returns a new StaticFS that can access the files on an underlying FS, but only if they are also specified in a static list, which is constructed when creating the object by calling Files() on the underlying FS.
type StaticRoute ¶
type StaticRouteResolver ¶
type StaticRouteResolver interface {
Routes(ctx context.Context) []*StaticRoute
}
type Store ¶
type Store interface { // Plugin finds a plugin by its ID. Plugin(ctx context.Context, pluginID string) (PluginDTO, bool) // Plugins returns plugins by their requested type. Plugins(ctx context.Context, pluginTypes ...Type) []PluginDTO }
Store is the publicly accessible storage for plugins.
type UpdateInfo ¶
type UpdateInfo struct {
PluginZipURL string
}
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package backendplugin contains backend plugin related logic.
|
Package backendplugin contains backend plugin related logic. |
instrumentation
Package instrumentation contains backend plugin instrumentation logic.
|
Package instrumentation contains backend plugin instrumentation logic. |
pipeline/termination
Package termination defines the Termination stage of the plugin loader pipeline.
|
Package termination defines the Termination stage of the plugin loader pipeline. |