package status

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

Package status implements status reporting.

Index

Constants

const Name = "status"

Name identifies the plugin on manager.

Types

type BundleLoadDurationNanoseconds

type BundleLoadDurationNanoseconds struct {
	Buckets []float64 `json:"buckets,omitempty"` // the float64 array of buckets representing nanoseconds or multiple of nanoseconds
}

BundleLoadDurationNanoseconds represents the configuration for the status.prometheus_config.bundle_loading_duration_ns settings

type Collectors

type Collectors struct {
	BundleLoadDurationNanoseconds *BundleLoadDurationNanoseconds `json:"bundle_loading_duration_ns,omitempty"`
}

type Config

type Config struct {
	Plugin           *string              `json:"plugin"`
	Service          string               `json:"service"`
	PartitionName    string               `json:"partition_name,omitempty"`
	ConsoleLogs      bool                 `json:"console"`
	Prometheus       bool                 `json:"prometheus"`
	PrometheusConfig *PrometheusConfig    `json:"prometheus_config,omitempty"`
	Trigger          *plugins.TriggerMode `json:"trigger,omitempty"` // trigger mode
}

Config contains configuration for the plugin.

func ParseConfig

func ParseConfig(config []byte, services []string, pluginsList []string) (*Config, error)

ParseConfig validates the config and injects default values.

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 plugin config.

func (*ConfigBuilder) Parse

func (b *ConfigBuilder) Parse() (*Config, error)

Parse validates the config and injects default values.

func (*ConfigBuilder) WithBytes

func (b *ConfigBuilder) WithBytes(config []byte) *ConfigBuilder

WithBytes sets the raw plugin config.

func (*ConfigBuilder) WithPlugins

func (b *ConfigBuilder) WithPlugins(plugins []string) *ConfigBuilder

WithPlugins sets the list of named plugins for status updates.

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 Logger

type Logger interface {
	plugins.Plugin

	Log(context.Context, *UpdateRequestV1) error
}

Logger defines the interface for status plugins.

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

Plugin implements status reporting. Updates can be triggered by the caller.

func Lookup

func Lookup(manager *plugins.Manager) *Plugin

Lookup returns the status plugin registered with the manager.

func New

func New(parsedConfig *Config, manager *plugins.Manager) *Plugin

New returns a new Plugin with the given config.

func (*Plugin) BulkUpdateBundleStatus

func (p *Plugin) BulkUpdateBundleStatus(status map[string]*bundle.Status)

BulkUpdateBundleStatus notifies the plugin that the policy bundle was updated.

func (*Plugin) Reconfigure

func (p *Plugin) Reconfigure(_ context.Context, config interface{})

Reconfigure notifies the plugin with a new configuration.

func (*Plugin) Snapshot

func (p *Plugin) Snapshot() *UpdateRequestV1

Snapshot returns the current status.

func (*Plugin) Start

func (p *Plugin) Start(ctx context.Context) error

Start starts the plugin.

func (*Plugin) Stop

func (p *Plugin) Stop(_ context.Context)

Stop stops the plugin.

func (*Plugin) Trigger

func (p *Plugin) Trigger(ctx context.Context) error

Trigger can be used to control when the plugin attempts to upload status in manual triggering mode.

func (*Plugin) UpdateBundleStatus

func (p *Plugin) UpdateBundleStatus(status bundle.Status)

UpdateBundleStatus notifies the plugin that the policy bundle was updated. Deprecated: Use BulkUpdateBundleStatus instead.

func (*Plugin) UpdateDecisionLogsStatus

func (p *Plugin) UpdateDecisionLogsStatus(status lstat.Status)

UpdateDecisionLogsStatus notifies the plugin that status of a decision log upload event.

func (*Plugin) UpdateDiscoveryStatus

func (p *Plugin) UpdateDiscoveryStatus(status bundle.Status)

UpdateDiscoveryStatus notifies the plugin that the discovery bundle was updated.

func (*Plugin) UpdatePluginStatus

func (p *Plugin) UpdatePluginStatus(status map[string]*plugins.Status)

UpdatePluginStatus notifies the plugin that a plugin status was updated.

func (*Plugin) WithMetrics

func (p *Plugin) WithMetrics(m metrics.Metrics) *Plugin

WithMetrics sets the global metrics provider to be used by the plugin.

type PrometheusConfig

type PrometheusConfig struct {
	Collectors *Collectors `json:"collectors,omitempty"`
}

type UpdateRequestV1

type UpdateRequestV1 struct {
	Labels       map[string]string          `json:"labels"`
	Bundle       *bundle.Status             `json:"bundle,omitempty"` // Deprecated: Use bulk `bundles` status updates instead
	Bundles      map[string]*bundle.Status  `json:"bundles,omitempty"`
	Discovery    *bundle.Status             `json:"discovery,omitempty"`
	DecisionLogs *lstat.Status              `json:"decision_logs,omitempty"`
	Metrics      map[string]interface{}     `json:"metrics,omitempty"`
	Plugins      map[string]*plugins.Status `json:"plugins,omitempty"`
}

UpdateRequestV1 represents the status update message that OPA sends to remote HTTP endpoints.

func (UpdateRequestV1) Equal

func (u UpdateRequestV1) Equal(other UpdateRequestV1) bool

Source Files

metrics.go plugin.go

Version
v1.4.2 (latest)
Published
May 2, 2025
Platform
linux/amd64
Imports
15 packages
Last checked
5 hours ago

Tools for package owners.