Documentation
¶
Index ¶
- Constants
- Variables
- func BatchLoadPolicy(ctx context.Context, maxPoliciesInBatch int, ...) error
- func RegisterDriver(name string, cons Constructor)
- func Reload(ctx context.Context, rs Reloadable) error
- func TestSubscription(s Subscribable) func(*testing.T, time.Duration, ...Event)
- type BinaryStore
- type Conf
- type Constructor
- type Event
- type EventKind
- type Instrumented
- type InvalidPolicyError
- type InvalidSchemaError
- type ListPolicyIDsParams
- type MutableStore
- type Reloadable
- type RepoStats
- type RuleTableStore
- type SourceStore
- type Store
- type Subscribable
- type Subscriber
- type SubscriptionManager
- type Verifiable
Constants ¶
const ConfKey = "storage"
const MaxPoliciesInBatch = 25
Variables ¶
var ErrPolicyIDCollision = errors.New("policy ID collision")
Functions ¶
func BatchLoadPolicy ¶ added in v0.35.0
func RegisterDriver ¶
func RegisterDriver(name string, cons Constructor)
RegisterDriver registers a storage driver.
func TestSubscription ¶
TestSubscription is a helper to test subscriptions.
Types ¶
type BinaryStore ¶ added in v0.20.0
type BinaryStore interface {
Store
Subscribable
// GetFirstMatch searches for the given module IDs in order and returns the first one found.
GetFirstMatch(context.Context, []namer.ModuleID) (*runtimev1.RunnablePolicySet, error)
// GetAll returns all modules that exist within the policy store
GetAll(context.Context) ([]*runtimev1.RunnablePolicySet, error)
// GetAllMatching returns all modules that exist for the provided module IDs
GetAllMatching(context.Context, []namer.ModuleID) ([]*runtimev1.RunnablePolicySet, error)
}
BinaryStore is implemented by stores that have pre-compiled policies in binary format.
type Conf ¶
type Conf struct {
// contains filtered or unexported fields
}
Conf is required configuration for storage. +desc=This section is required. The field driver must be set to indicate which driver to use.
type Constructor ¶
Constructor is a constructor function for a storage driver.
func GetDriverConstructor ¶ added in v0.27.0
func GetDriverConstructor(name string) (Constructor, error)
GetDriverConstructor registers a storage driver.
type Event ¶
type Event struct {
OldPolicyID *namer.ModuleID
SchemaFile string
Dependents []namer.ModuleID
Kind EventKind
PolicyID namer.ModuleID
}
Event is an event detected by the storage layer.
func NewPolicyEvent ¶ added in v0.11.0
NewPolicyEvent creates a new storage event for a policy.
func NewReloadEvent ¶ added in v0.21.0
func NewReloadEvent() Event
NewReloadEvent creates a new reload event.
func NewSchemaEvent ¶ added in v0.11.0
NewSchemaEvent creates a new storage event for a schema.
type EventKind ¶
type EventKind int
EventKind identifies the kind of storage event such as addition or deletion.
type Instrumented ¶ added in v0.15.0
Instrumented stores expose repository stats.
type InvalidPolicyError ¶
InvalidPolicyError is a custom error to signal that a policy is invalid.
func NewInvalidPolicyError ¶
func NewInvalidPolicyError(err error, msg string, args ...any) InvalidPolicyError
func (InvalidPolicyError) Error ¶
func (ipe InvalidPolicyError) Error() string
func (InvalidPolicyError) Unwrap ¶
func (ipe InvalidPolicyError) Unwrap() error
type InvalidSchemaError ¶ added in v0.12.0
InvalidSchemaError is a custom error to signal that a schema is invalid.
func NewInvalidSchemaError ¶ added in v0.12.0
func NewInvalidSchemaError(err error, msg string, args ...any) InvalidSchemaError
func (InvalidSchemaError) Error ¶ added in v0.12.0
func (ise InvalidSchemaError) Error() string
func (InvalidSchemaError) Unwrap ¶ added in v0.12.0
func (ise InvalidSchemaError) Unwrap() error
type ListPolicyIDsParams ¶ added in v0.29.0
type MutableStore ¶
type MutableStore interface {
Store
AddOrUpdate(context.Context, ...policy.Wrapper) error
AddOrUpdateSchema(context.Context, ...*schemav1.Schema) error
Disable(context.Context, ...string) (uint32, error)
Enable(context.Context, ...string) (uint32, error)
DeleteSchema(context.Context, ...string) (uint32, error)
Delete(context.Context, ...namer.ModuleID) error
}
MutableStore is a store that allows mutations.
type Reloadable ¶ added in v0.20.0
Reloadable stores allow reloading their contents.
type RuleTableStore ¶ added in v0.48.0
RuleTableStore is implemented by stores that have pre-compiled rule tables.
type SourceStore ¶ added in v0.20.0
type SourceStore interface {
Store
// GetFirstMatch searches for the given module IDs in order and returns the first one found.
GetFirstMatch(context.Context, []namer.ModuleID) (*policy.CompilationUnit, error)
// GetAll returns all modules that exist within the policy store
GetAll(context.Context) ([]*policy.CompilationUnit, error)
// GetAllMatching returns all modules that exist for the provided module IDs
GetAllMatching(context.Context, []namer.ModuleID) ([]*policy.CompilationUnit, error)
// GetCompilationUnits gets the compilation units for the given module IDs.
GetCompilationUnits(context.Context, ...namer.ModuleID) (map[namer.ModuleID]*policy.CompilationUnit, error)
// GetDependents returns the dependents of the given modules.
GetDependents(context.Context, ...namer.ModuleID) (map[namer.ModuleID][]namer.ModuleID, error)
// LoadPolicy loads the given policy from the store
LoadPolicy(context.Context, ...string) ([]*policy.Wrapper, error)
}
SourceStore is implemented by stores that have policies in their source format (uncompiled).
type Store ¶
type Store interface {
// Driver is the name of the storage backend implementation.
Driver() string
// InspectPolicies returns inspection results for the policies in the store.
InspectPolicies(context.Context, ListPolicyIDsParams) (map[string]*responsev1.InspectPoliciesResponse_Result, error)
// ListPolicyIDs returns the policy IDs in the store.
ListPolicyIDs(context.Context, ListPolicyIDsParams) ([]string, error)
// ListSchemaIDs returns the schema ids in the store.
ListSchemaIDs(context.Context) ([]string, error)
// LoadSchema loads the given schema from the store.
LoadSchema(context.Context, string) (io.ReadCloser, error)
// Source returns metadata for inclusion in audit logs.
Source() *auditv1.PolicySource
}
Store is the common interface implemented by storage backends.
type Subscribable ¶
type Subscribable interface {
// Subscribe adds a subscriber to listen for storage notifications.
Subscribe(Subscriber)
// Unsubscribe removes a subscriber.
Unsubscribe(Subscriber)
}
Subscribable is an interface for managing subscriptions to storage events.
type Subscriber ¶
Subscriber is the interface implemented by storage subscribers.
type SubscriptionManager ¶
type SubscriptionManager struct {
// contains filtered or unexported fields
}
func NewSubscriptionManager ¶
func NewSubscriptionManager(ctx context.Context) *SubscriptionManager
func (*SubscriptionManager) NotifySubscribers ¶
func (sm *SubscriptionManager) NotifySubscribers(events ...Event)
Notify sends the events to all subscribers.
func (*SubscriptionManager) Subscribe ¶
func (sm *SubscriptionManager) Subscribe(s Subscriber)
func (*SubscriptionManager) Unsubscribe ¶
func (sm *SubscriptionManager) Unsubscribe(s Subscriber)
type Verifiable ¶ added in v0.27.0
Verifiable stores allow querying whether the requirements for the store are met.