plugins

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package plugins contains the interface for using plugins to extend the functionality of the node.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnsupported is returned when a plugin capability is not supported
	// by any of the registered plugins.
	ErrUnsupported = status.Error(codes.Unimplemented, "unsupported plugin capability")
)

Functions

func Serve

func Serve(ctx context.Context, plugin v1.PluginServer) error

Serve is a convenience function for serving a plugin. It should be used by plugins that are intended to be run as a separate process.

Types

type Config

type Config struct {
	// Plugin is an inline plugin implementation.
	Plugin v1.PluginServer `yaml:"-" json:"-" toml:"-"`
	// Path is the path to an executable for the plugin.
	Path string `yaml:"path,omitempty" json:"path,omitempty" toml:"path,omitempty"`
	// Server is the address of a server for the plugin.
	Server string `yaml:"server,omitempty" json:"server,omitempty" toml:"server,omitempty"`
	// Insecure is whether to use an insecure connection to the plugin server.
	Insecure bool `yaml:"insecure,omitempty" json:"insecure,omitempty" toml:"insecure,omitempty"`
	// TLSCAFile is the path to a CA for verifying certificates.
	TLSCAFile string `yaml:"tls-ca-file,omitempty" json:"tls-ca-file,omitempty" toml:"tls-ca-file,omitempty"`
	// TLSCertFile is the path to a certificate for authenticating to the plugin server.
	TLSCertFile string `yaml:"tls-cert-file,omitempty" json:"tls-cert-file,omitempty" toml:"tls-cert-file,omitempty"`
	// TLSKeyFile is the path to a key for authenticating to the plugin server.
	TLSKeyFile string `yaml:"tls-key-file,omitempty" json:"tls-key-file,omitempty" toml:"tls-key-file,omitempty"`
	// TLSSkipVerify is whether to skip verifying the plugin server's certificate.
	TLSSkipVerify bool `yaml:"tls-skip-verify,omitempty" json:"tls-skip-verify,omitempty" toml:"tls-skip-verify,omitempty"`
	// Config is the configuration for the plugin.
	Config map[string]any `yaml:"config,omitempty" json:"config,omitempty" toml:"config,omitempty"`
}

Config is the configuration for a plugin.

type Manager

type Manager interface {
	// Get returns the plugin with the given name.
	Get(name string) (v1.PluginClient, bool)
	// ServeStorage handles queries from plugins against the given storage backend.
	ServeStorage(db storage.Storage)
	// HasAuth returns true if the manager has an auth plugin.
	HasAuth() bool
	// AuthUnaryInterceptor returns a unary interceptor for the configured auth plugin.
	// If no plugin is configured, the returned function is a pass-through.
	AuthUnaryInterceptor() grpc.UnaryServerInterceptor
	// AuthStreamInterceptor returns a stream interceptor for the configured auth plugin.
	// If no plugin is configured, the returned function is a pass-through.
	AuthStreamInterceptor() grpc.StreamServerInterceptor
	// AllocateIP calls the configured IPAM plugin to allocate an IP address for the given request.
	// If the requested version does not have a registered plugin, ErrUnsupported is returned.
	AllocateIP(ctx context.Context, req *v1.AllocateIPRequest) (netip.Prefix, error)
	// ApplyRaftLog applies a raft log entry to all storage plugins. Responses are still returned
	// even if an error occurs.
	ApplyRaftLog(ctx context.Context, entry *v1.StoreLogRequest) ([]*v1.RaftApplyResponse, error)
	// ApplySnapshot applies a snapshot to all storage plugins.
	ApplySnapshot(ctx context.Context, meta *raft.SnapshotMeta, data io.ReadCloser) error
	// Emit emits an event to all watch plugins.
	Emit(ctx context.Context, ev *v1.Event) error
	// Close closes all plugins.
	Close() error
}

Manager is the interface for managing plugins.

func NewManager

func NewManager(ctx context.Context, opts *Options) (Manager, error)

NewManager creates a new plugin manager.

type Options

type Options struct {
	// Plugins is a map of plugin names to plugin configs.
	Plugins map[string]*Config `yaml:",inline" json:",inline" toml:",inline"`
}

Options are the options for loading plugins.

func NewOptions

func NewOptions() *Options

NewOptions creates new options.

func (*Options) BindFlags

func (o *Options) BindFlags(fs *flag.FlagSet)

BindFlags binds the plugin flags to the given flag set.

Directories

Path Synopsis
Package basicauth is an authentication plugin that uses basic auth.
Package basicauth is an authentication plugin that uses basic auth.
Package clients contains the interface for using plugin clients.
Package clients contains the interface for using plugin clients.
Package ipam provides a plugin for simple mesh IPAM.
Package ipam provides a plugin for simple mesh IPAM.
Package ldap implements a basic LDAP authentication plugin.
Package ldap implements a basic LDAP authentication plugin.
Package mtls is an authentication plugin that uses mTLS.
Package mtls is an authentication plugin that uses mTLS.
Package plugindb contains a SQL driver for running data queries over a Plugin Query stream.
Package plugindb contains a SQL driver for running data queries over a Plugin Query stream.

Jump to

Keyboard shortcuts

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