package plugins

import "github.com/open-policy-agent/opa/plugins"

Package plugins implements plugin management for the policy engine.

Index

Functions

func Info

func Info(term *ast.Term) func(*Manager)

Info sets the runtime information on the manager. The runtime information is propagated to opa.runtime() built-in function calls.

Types

type Manager

type Manager struct {
	Store  storage.Store
	Config *config.Config
	Info   *ast.Term
	ID     string
	// contains filtered or unexported fields
}

Manager implements lifecycle management of plugins and gives plugins access to engine-wide components like storage.

func New

func New(raw []byte, id string, store storage.Store, opts ...func(*Manager)) (*Manager, error)

New creates a new Manager using config.

func (*Manager) Client

func (m *Manager) Client(name string) rest.Client

Client returns a client for communicating with a remote service.

func (*Manager) GetCompiler

func (m *Manager) GetCompiler() *ast.Compiler

GetCompiler returns the manager's compiler.

func (*Manager) Labels

func (m *Manager) Labels() map[string]string

Labels returns the set of labels from the configuration.

func (*Manager) Plugin

func (m *Manager) Plugin(name string) Plugin

Plugin returns the plugin registered with name or nil if name is not found.

func (*Manager) Plugins

func (m *Manager) Plugins() []string

Plugins returns the list of plugins registered with the manager.

func (*Manager) Reconfigure

func (m *Manager) Reconfigure(config *config.Config) error

Reconfigure updates the configuration on the manager.

func (*Manager) Register

func (m *Manager) Register(name string, plugin Plugin)

Register adds a plugin to the manager. When the manager is started, all of the plugins will be started.

func (*Manager) RegisterCompilerTrigger

func (m *Manager) RegisterCompilerTrigger(f func(txn storage.Transaction))

RegisterCompilerTrigger registers for change notifications when the compiler is changed.

func (*Manager) Services

func (m *Manager) Services() []string

Services returns a list of services that m can provide clients for.

func (*Manager) Start

func (m *Manager) Start(ctx context.Context) error

Start starts the manager.

func (*Manager) Stop

func (m *Manager) Stop(ctx context.Context)

Stop stops the manager, stopping all the plugins registered with it

type Plugin

type Plugin interface {
	Start(ctx context.Context) error
	Stop(ctx context.Context)
	Reconfigure(ctx context.Context, config interface{})
}

Plugin defines the interface for OPA plugins.

type PluginInitFunc

type PluginInitFunc func(m *Manager, config []byte) (Plugin, error)

PluginInitFunc defines the interface for the constructing plugins from configuration. The function will be called with the plugin manager (which provides access to OPA's storage layer, compiler, and service clients) and the configuration for the plugin itself.

Source Files

plugins.go

Directories

PathSynopsis
plugins/bundlePackage bundle implements bundle downloading.
plugins/discoveryPackage discovery implements configuration discovery.
plugins/logsPackage logs implements decision log buffering and uploading.
plugins/restPackage rest implements a REST client for communicating with remote services.
plugins/statusPackage status implements status reporting.
Version
v0.10.2
Published
Dec 10, 2018
Platform
js/wasm
Imports
8 packages
Last checked
2 minutes ago

Tools for package owners.