Package plugins implements plugin management for the policy engine.
Info sets the runtime information on the manager. The runtime information is propagated to opa.runtime() built-in function calls.
Factory defines the interface OPA uses to instantiate your plugin.
When OPA processes it's configuration it looks for factories that have been registered by calling runtime.RegisterPlugin. Factories are registered to a name which is used to key into the configuration blob. If your plugin has not been configured, your factory will not be invoked.
plugins: my_plugin1: some_key: foo # my_plugin2: # some_key2: bar
If OPA was started with the configuration above and received two calls to runtime.RegisterPlugins (one with NAME "my_plugin1" and one with NAME "my_plugin2"), it would only invoke the factory for for my_plugin1.
OPA instantiates and reconfigures plugins in two steps. First, OPA will call Validate to check the configuration. Assuming the configuration is valid, your factory should return a configuration value that can be used to construct your plugin. Second, OPA will call New to instantiate your plugin providing the configuration value returned from the Validate call.
Validate receives a slice of bytes representing plugin configuration and returns a configuration value that can be used to instantiate your plugin. The manager is provided to give access to the OPA's compiler, storage layer, adn global configuration. Your Validate function will typically:
1. Deserialize the raw config bytes 2. Validate the deserialized config for semantic errors 3. Inject default values 4. Return a deserialized/parsed config
New receives a valid configuration for your plugin and returns a plugin object. Your New function will typically:
1. Cast the config value to it's own type 2. Instantiate a plugin object 3. Return the plugin object
Manager implements lifecycle management of plugins and gives plugins access to engine-wide components like storage.
New creates a new Manager using config.
Client returns a client for communicating with a remote service.
GetCompiler returns the manager's compiler.
Labels returns the set of labels from the configuration.
Plugin returns the plugin registered with name or nil if name is not found.
Plugins returns the list of plugins registered with the manager.
Reconfigure updates the configuration on the manager.
Register adds a plugin to the manager. When the manager is started, all of the plugins will be started.
RegisterCompilerTrigger registers for change notifications when the compiler is changed.
Services returns a list of services that m can provide clients for.
Start starts the manager.
Stop stops the manager, stopping all the plugins registered with it
Plugin defines the interface OPA uses to manage your plugin.
When OPA starts it will start all of the plugins it was configured to instantiate. Each time a new plugin is configured (via discovery), OPA will start it. You can use the Start call to spawn additional goroutines or perform initialization tasks.
Currently OPA will not call Stop on plugins.
When OPA receives new configuration for your plugin via discovery it will first Validate the configuration using your factory and then call Reconfigure.
|bundle||Package bundle implements bundle downloading.|
|discovery||Package discovery implements configuration discovery.|
|logs||Package logs implements decision log buffering and uploading.|
|rest||Package rest implements a REST client for communicating with remote services.|
|status||Package status implements status reporting.|