package config

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

Package config implements OPA configuration file parsing and validation.

Index

Types

type Config

type Config struct {
	Services                     json.RawMessage            `json:"services,omitempty"`
	Labels                       map[string]string          `json:"labels,omitempty"`
	Discovery                    json.RawMessage            `json:"discovery,omitempty"`
	Bundle                       json.RawMessage            `json:"bundle,omitempty"` // Deprecated: Use `bundles` instead
	Bundles                      json.RawMessage            `json:"bundles,omitempty"`
	DecisionLogs                 json.RawMessage            `json:"decision_logs,omitempty"`
	Status                       json.RawMessage            `json:"status,omitempty"`
	Plugins                      map[string]json.RawMessage `json:"plugins,omitempty"`
	Keys                         json.RawMessage            `json:"keys,omitempty"`
	DefaultDecision              *string                    `json:"default_decision,omitempty"`
	DefaultAuthorizationDecision *string                    `json:"default_authorization_decision,omitempty"`
	Caching                      json.RawMessage            `json:"caching,omitempty"`
	PersistenceDirectory         *string                    `json:"persistence_directory,omitempty"`
}

Config represents the configuration file that OPA can be started with.

func ParseConfig

func ParseConfig(raw []byte, id string) (*Config, error)

ParseConfig returns a valid Config object with defaults injected. The id and version parameters will be set in the labels map.

func (*Config) ActiveConfig

func (c *Config) ActiveConfig() (interface{}, error)

ActiveConfig returns OPA's active configuration with the credentials and crypto keys removed

func (Config) DefaultAuthorizationDecisionRef

func (c Config) DefaultAuthorizationDecisionRef() ast.Ref

DefaultAuthorizationDecisionRef returns the default authorization decision as a reference.

func (Config) DefaultDecisionRef

func (c Config) DefaultDecisionRef() ast.Ref

DefaultDecisionRef returns the default decision as a reference.

func (Config) GetPersistenceDirectory

func (c Config) GetPersistenceDirectory() (string, error)

GetPersistenceDirectory returns the configured persistence directory, or $PWD/.opa if none is configured

func (Config) PluginsEnabled

func (c Config) PluginsEnabled() bool

PluginsEnabled returns true if one or more plugin features are enabled.

Source Files

config.go

Version
v0.35.0-rc1
Published
Nov 5, 2021
Platform
js/wasm
Imports
8 packages
Last checked
3 seconds ago

Tools for package owners.