package bundle
import "github.com/open-policy-agent/opa/v1/plugins/bundle"
Package bundle implements bundle loading.
Index ¶
- Constants
- type Config
- func ParseBundlesConfig(config []byte, services []string) (*Config, error)
- func ParseConfig(config []byte, services []string) (*Config, error)
- func (c *Config) IsMultiBundle() bool
- type ConfigBuilder
- func NewConfigBuilder() *ConfigBuilder
- func (b *ConfigBuilder) Parse() (*Config, error)
- func (b *ConfigBuilder) WithBytes(config []byte) *ConfigBuilder
- func (b *ConfigBuilder) WithKeyConfigs(keys map[string]*keys.Config) *ConfigBuilder
- func (b *ConfigBuilder) WithServices(services []string) *ConfigBuilder
- func (b *ConfigBuilder) WithTriggerMode(trigger *plugins.TriggerMode) *ConfigBuilder
- type Error
- func NewBundleError(bundleName string, cause error) Error
- func (e Error) Error() string
- func (e Error) Unwrap() error
- type Errors
- type Loader
- type Plugin
- func Lookup(manager *plugins.Manager) *Plugin
- func New(parsedConfig *Config, manager *plugins.Manager) *Plugin
- func (p *Plugin) Config() *Config
- func (p *Plugin) Loaders() map[string]Loader
- func (p *Plugin) Reconfigure(ctx context.Context, config interface{})
- func (p *Plugin) Register(name interface{}, listener func(Status))
- func (p *Plugin) RegisterBulkListener(name interface{}, listener func(map[string]*Status))
- func (p *Plugin) Start(ctx context.Context) error
- func (p *Plugin) Stop(ctx context.Context)
- func (p *Plugin) Trigger(ctx context.Context) error
- func (p *Plugin) Unregister(name interface{})
- func (p *Plugin) UnregisterBulkListener(name interface{})
- type Source
- type Status
Constants ¶
const Name = "bundle"
Name identifies the plugin on manager.
Types ¶
type Config ¶
type Config struct { download.Config // Deprecated: Use `Bundles` map instead Bundles map[string]*Source Name string `json:"name"` // Deprecated: Use `Bundles` map instead Service string `json:"service"` // Deprecated: Use `Bundles` map instead Prefix *string `json:"prefix"` // Deprecated: Use `Bundles` map instead }
Config represents the configuration of the plugin. The Config can define a single bundle source or a map of `Source` objects defining where/how to download bundles. The older single bundle configuration is deprecated and will be removed in the future in favor of the `Bundles` map.
func ParseBundlesConfig ¶
ParseBundlesConfig validates the config and injects default values for the defined `bundles`. This expects a map of bundle names to resource configurations.
func ParseConfig ¶
ParseConfig validates the config and injects default values. This is for the legacy single bundle configuration. This will add the bundle to the `Bundles` map to provide compatibility with newer clients. Deprecated: Use `ParseBundlesConfig` with `bundles` OPA config option instead
func (*Config) IsMultiBundle ¶
IsMultiBundle returns whether or not the config is the newer multi-bundle style config that uses `bundles` instead of top level bundle information. If/when we drop support for the older style config we can remove this too.
type ConfigBuilder ¶
type ConfigBuilder struct {
// contains filtered or unexported fields
}
ConfigBuilder assists in the construction of the plugin configuration.
func NewConfigBuilder ¶
func NewConfigBuilder() *ConfigBuilder
NewConfigBuilder returns a new ConfigBuilder to build and parse the bundle config
func (*ConfigBuilder) Parse ¶
func (b *ConfigBuilder) Parse() (*Config, error)
Parse validates the config and injects default values for the defined `bundles`.
func (*ConfigBuilder) WithBytes ¶
func (b *ConfigBuilder) WithBytes(config []byte) *ConfigBuilder
WithBytes sets the raw bundle config
func (*ConfigBuilder) WithKeyConfigs ¶
func (b *ConfigBuilder) WithKeyConfigs(keys map[string]*keys.Config) *ConfigBuilder
WithKeyConfigs sets the public keys to verify a signed bundle
func (*ConfigBuilder) WithServices ¶
func (b *ConfigBuilder) WithServices(services []string) *ConfigBuilder
WithServices sets the services that implement control plane APIs
func (*ConfigBuilder) WithTriggerMode ¶
func (b *ConfigBuilder) WithTriggerMode(trigger *plugins.TriggerMode) *ConfigBuilder
WithTriggerMode sets the plugin trigger mode
type Error ¶
func NewBundleError ¶
func (Error) Error ¶
func (Error) Unwrap ¶
type Errors ¶
type Errors []Error
Errors represents a list of errors that occurred during a bundle load enriched by the bundle name.
func (Errors) Error ¶
func (Errors) Unwrap ¶
type Loader ¶
type Loader interface { Start(context.Context) Stop(context.Context) Trigger(context.Context) error SetCache(string) ClearCache() }
Loader defines the interface that the bundle plugin uses to control bundle loading via HTTP, disk, etc.
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
Plugin implements bundle activation.
func Lookup ¶
Lookup returns the bundle plugin registered with the manager.
func New ¶
New returns a new Plugin with the given config.
func (*Plugin) Config ¶
Config returns the plugins current configuration
func (*Plugin) Loaders ¶
Loaders returns the map of bundle loaders configured on this plugin.
func (*Plugin) Reconfigure ¶
Reconfigure notifies the plugin that it's configuration has changed. Any bundle configs that have changed or been added/removed will take affect.
func (*Plugin) Register ¶
Register a listener to receive status updates. The name must be comparable. The listener will receive a status update for each bundle configured, they are not going to be aggregated. For all status updates use `RegisterBulkListener`.
func (*Plugin) RegisterBulkListener ¶
RegisterBulkListener registers a listener to receive bulk (aggregated) status updates. The name must be comparable.
func (*Plugin) Start ¶
Start runs the plugin. The plugin will periodically try to download bundles from the configured service. When a new bundle is downloaded, the data and policies are extracted and inserted into storage.
func (*Plugin) Stop ¶
Stop stops the plugin.
func (*Plugin) Trigger ¶
Trigger triggers a bundle download on all configured bundles.
func (*Plugin) Unregister ¶
func (p *Plugin) Unregister(name interface{})
Unregister a listener to stop receiving status updates.
func (*Plugin) UnregisterBulkListener ¶
func (p *Plugin) UnregisterBulkListener(name interface{})
UnregisterBulkListener unregisters a listener to stop receiving aggregated status updates.
type Source ¶
type Source struct { download.Config Service string `json:"service"` Resource string `json:"resource"` Signing *bundle.VerificationConfig `json:"signing"` Persist bool `json:"persist"` SizeLimitBytes int64 `json:"size_limit_bytes"` }
Source is a configured bundle source to download bundles from
type Status ¶
type Status struct { Name string `json:"name"` ActiveRevision string `json:"active_revision,omitempty"` LastSuccessfulActivation time.Time `json:"last_successful_activation,omitempty"` Type string `json:"type,omitempty"` Size int `json:"size,omitempty"` LastSuccessfulDownload time.Time `json:"last_successful_download,omitempty"` LastSuccessfulRequest time.Time `json:"last_successful_request,omitempty"` LastRequest time.Time `json:"last_request,omitempty"` Code string `json:"code,omitempty"` Message string `json:"message,omitempty"` Errors []error `json:"errors,omitempty"` Metrics metrics.Metrics `json:"metrics,omitempty"` HTTPCode json.Number `json:"http_code,omitempty"` }
Status represents the status of processing a bundle.
func (*Status) Equal ¶
func (*Status) SetActivateSuccess ¶
SetActivateSuccess updates the status object to reflect a successful activation.
func (*Status) SetBundleSize ¶
func (*Status) SetDownloadSuccess ¶
func (s *Status) SetDownloadSuccess()
SetDownloadSuccess updates the status object to reflect a successful download.
func (*Status) SetError ¶
SetError updates the status object to reflect a failure to download or activate. If err is nil, the error status is cleared.
func (*Status) SetRequest ¶
func (s *Status) SetRequest()
SetRequest updates the status object to reflect a download attempt.
Source Files ¶
config.go errors.go plugin.go status.go
- Version
- v1.4.2 (latest)
- Published
- May 2, 2025
- Platform
- linux/amd64
- Imports
- 27 packages
- Last checked
- 4 hours ago –
Tools for package owners.