mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-13 03:42:35 -06:00
5a872a4166
This commit adds support for changing out how bundle storage and activation work. To allow swapping out bundle activation, two new `bundle` package functions are provided: - `RegisterActivator`: Registers a bundle.Activator with a string ID. - `RegisterDefaultBundleActivator`: Sets the default bundle.Activator to use by ID. Behind the scenes, a few new `bundle` package variables are used to track what bundle activators are available, and which is the preferred default. This system allows registering many activators, and allows choosing the bundle activator to use at activation time. The activator to use is decided in the following order: - `(bundle.ActivateOpts).Plugin` is used when non-nil. - `bundle.bundleExtActivator` is used when an ID was set with `RegisterDefaultBundleActivator`. - The default/original bundle activator is used if no other selection was made. To support swapping out bundle storage (useful when testing new bundle designs), a new `bundle` package function is provided: - `RegisterStoreFunc`: Sets the function to use for creating bundle storage. These two features together allow swapping out most of the bundle activation flow, without requiring deep modification of the `bundle` package. Lazy bundle loading mode is also enabled across many CLI commands and other bundle loading points now when a non-default bundle activator is set. Signed-off-by: Philip Conrad <philip@chariot-chaser.net> Co-authored-by: Ashutosh Narkar <anarkar4387@gmail.com>