plugins

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Overview

Package plugins contains the plugin manager.

Package plugins contains the plugin manager.

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 NewAuthStreamInterceptor added in v0.15.0

func NewAuthStreamInterceptor(plugin v1.AuthPluginClient) grpc.StreamServerInterceptor

NewAuthStreamInterceptor returns a stream interceptor for the given auth plugin.

func NewAuthUnaryInterceptor added in v0.15.0

func NewAuthUnaryInterceptor(plugin v1.AuthPluginClient) grpc.UnaryServerInterceptor

NewAuthUnaryInterceptor returns a unary interceptor for the given auth plugin.

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 BuiltinIPAM added in v0.11.0

type BuiltinIPAM struct {
	v1.UnimplementedIPAMPluginServer

	IPAMConfig
	// contains filtered or unexported fields
}

BuiltinIPAM is the built-in IPAM plugin that uses the mesh database to perform allocations.

func NewBuiltinIPAM added in v0.11.0

func NewBuiltinIPAM(opts IPAMConfig) *BuiltinIPAM

NewBuiltinIPAM returns a new ipam plugin with the given database.

func (*BuiltinIPAM) Allocate added in v0.11.0

func (p *BuiltinIPAM) Allocate(ctx context.Context, r *v1.AllocateIPRequest, opts ...grpc.CallOption) (*v1.AllocatedIP, error)

func (*BuiltinIPAM) Release added in v0.11.2

func (p *BuiltinIPAM) Release(ctx context.Context, req *v1.ReleaseIPRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)

type IPAMConfig added in v0.11.0

type IPAMConfig struct {
	// Storage is the storage plugin to use for IPAM.
	Storage storage.MeshDB
	// StaticIPv4 is a map of node names to IPv4 addresses.
	StaticIPv4 map[string]string
}

IPAMConfig contains static address assignments for nodes.

type IPAMPlugin added in v0.11.0

type IPAMPlugin interface {
	Allocate(ctx context.Context, r *v1.AllocateIPRequest, opts ...grpc.CallOption) (*v1.AllocatedIP, error)
	Release(ctx context.Context, r *v1.ReleaseIPRequest, opts ...grpc.CallOption) (*emptypb.Empty, error)
}

IPAMPlugin wraps the interface of the IPAM plugin only exposing the Allocate method. This makes for ease of use with the built-in IPAM.

type Manager

type Manager interface {
	// Get returns the plugin with the given name.
	Get(name string) (clients.PluginClient, bool)
	// HasAuth returns true if the manager has an auth plugin.
	HasAuth() bool
	// HasWatchers returns true if the manager has any watch plugins.
	HasWatchers() 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 no IPAM plugin is configured, ErrUnsupported is returned.
	AllocateIP(ctx context.Context, req *v1.AllocateIPRequest) (netip.Prefix, error)
	// ReleaseIP calls the configured IPAM plugin to release an IP address for the given request.
	// If no IPAM plugin is configured, ErrUnsupported is returned.
	ReleaseIP(ctx context.Context, req *v1.ReleaseIPRequest) 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.

func NewManagerWithDB added in v0.10.5

func NewManagerWithDB(db storage.Provider) Manager

NewManagerWithDB creates a new plugin manager with a storage provider and no plugins configured.

type NodeConfig added in v0.14.14

type NodeConfig struct {
	// NodeID is the ID of the node.
	NodeID types.NodeID
	// NetworkIPv4 is the IPv4 network of the mesh
	NetworkIPv4 netip.Prefix
	// NetworkIPv6 is the IPv6 network of the mesh
	NetworkIPv6 netip.Prefix
	// AddressIPv4 is the IPv4 address of the node
	AddressIPv4 netip.Prefix
	// AddressIPv6 is the IPv6 address of the node
	AddressIPv6 netip.Prefix
	// Domain is the domain of the mesh
	Domain string
	// Key is the node's private key
	Key crypto.PrivateKey
}

NodeConfig is the configuration of the node to pass to each plugin.

type Options

type Options struct {
	// Storage is the storage backend to use for plugins.
	Storage storage.Provider
	// Plugins is a map of plugin names to plugin configs.
	Plugins map[string]Plugin
	// Node is the node configuration to pass to each plugin.
	Node NodeConfig
	// DisableDefaultIPAM disables the default IPAM plugin.
	DisableDefaultIPAM bool
	// DefaultIPAMStaticIPv4 is a map of node names to IPv4 addresses.
	DefaultIPAMStaticIPv4 map[string]string
}

Options are the options for creating a new plugin manager.

type Plugin added in v0.3.1

type Plugin struct {
	// Client is the plugin client.
	Client clients.PluginClient
	// Config is the plugin configuration.
	Config map[string]any
	// contains filtered or unexported fields
}

Plugin represents a plugin client and its configuration.

Directories

Path Synopsis
Package builtins contains the built-in plugin implementations.
Package builtins contains the built-in plugin implementations.
basicauth
Package basicauth is an authentication plugin that uses basic auth.
Package basicauth is an authentication plugin that uses basic auth.
debug
Package debug implements a plugin that exposes an HTTP server for debugging purposes.
Package debug implements a plugin that exposes an HTTP server for debugging purposes.
idauth
Package idauth is an authentication plugin based on libp2p peer IDs.
Package idauth is an authentication plugin based on libp2p peer IDs.
ldap
Package ldap implements a basic LDAP authentication plugin.
Package ldap implements a basic LDAP authentication plugin.
mtls
Package mtls is an authentication plugin that uses mTLS.
Package mtls is an authentication plugin that uses mTLS.
Package clients contains the interface for using plugin clients.
Package clients contains the interface for using plugin clients.

Jump to

Keyboard shortcuts

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