storage

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 3 Imported by: 276

Documentation

Overview

Package storage exposes the policy engine's storage layer.

Deprecated: This package is intended for older projects transitioning from OPA v0.x and will remain for the lifetime of OPA v1.x, but its use is not recommended. For newer features and behaviours, such as defaulting to the Rego v1 syntax, use the corresponding components in the github.com/open-policy-agent/opa/v1 package instead. See https://www.openpolicyagent.org/docs/latest/v0-compatibility/ for more information.

Index

Constants

View Source
const (
	// InternalErr indicates an unknown, internal error has occurred.
	InternalErr = v1.InternalErr

	// NotFoundErr indicates the path used in the storage operation does not
	// locate a document.
	NotFoundErr = v1.NotFoundErr

	// WriteConflictErr indicates a write on the path enocuntered a conflicting
	// value inside the transaction.
	WriteConflictErr = v1.WriteConflictErr

	// InvalidPatchErr indicates an invalid patch/write was issued. The patch
	// was rejected.
	InvalidPatchErr = v1.InvalidPatchErr

	// InvalidTransactionErr indicates an invalid operation was performed
	// inside of the transaction.
	InvalidTransactionErr = v1.InvalidTransactionErr

	// TriggersNotSupportedErr indicates the caller attempted to register a
	// trigger against a store that does not support them.
	TriggersNotSupportedErr = v1.TriggersNotSupportedErr

	// WritesNotSupportedErr indicate the caller attempted to perform a write
	// against a store that does not support them.
	WritesNotSupportedErr = v1.WritesNotSupportedErr

	// PolicyNotSupportedErr indicate the caller attempted to perform a policy
	// management operation against a store that does not support them.
	PolicyNotSupportedErr = v1.PolicyNotSupportedErr
)
View Source
const (
	AddOp     = v1.AddOp
	RemoveOp  = v1.RemoveOp
	ReplaceOp = v1.ReplaceOp
)

Patch supports add, remove, and replace operations.

Variables

View Source
var WriteParams = v1.WriteParams

WriteParams specifies the TransactionParams for a write transaction.

Functions

func IsIndexingNotSupported deprecated added in v0.5.0

func IsIndexingNotSupported(err error) bool

IsIndexingNotSupported is a stub for backwards-compatibility.

Deprecated: We no longer return IndexingNotSupported errors, so it is unnecessary to check for them.

func IsInvalidPatch added in v0.2.0

func IsInvalidPatch(err error) bool

IsInvalidPatch returns true if this error is a InvalidPatchErr.

func IsInvalidTransaction added in v0.5.0

func IsInvalidTransaction(err error) bool

IsInvalidTransaction returns true if this error is a InvalidTransactionErr.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if this error is a NotFoundErr.

func IsWriteConflictError added in v0.8.0

func IsWriteConflictError(err error) bool

IsWriteConflictError returns true if this error a WriteConflictErr.

func MakeDir added in v0.8.0

func MakeDir(ctx context.Context, store Store, txn Transaction, path Path) error

MakeDir inserts an empty object at path. If the parent path does not exist, MakeDir will create it recursively.

func NonEmpty added in v0.10.4

func NonEmpty(ctx context.Context, store Store, txn Transaction) func([]string) (bool, error)

NonEmpty returns a function that tests if a path is non-empty. A path is non-empty if a Read on the path returns a value or a Read on any of the path prefixes returns a non-object value.

func ReadOne added in v0.5.3

func ReadOne(ctx context.Context, store Store, path Path) (interface{}, error)

ReadOne is a convenience function to read a single value from the provided Store. It will create a new Transaction to perform the read with, and clean up after itself should an error occur.

func Txn added in v0.5.9

func Txn(ctx context.Context, store Store, params TransactionParams, f func(Transaction) error) error

Txn is a convenience function that executes f inside a new transaction opened on the store. If the function returns an error, the transaction is aborted and the error is returned. Otherwise, the transaction is committed and the result of the commit is returned.

func WriteOne added in v0.5.3

func WriteOne(ctx context.Context, store Store, op PatchOp, path Path, value interface{}) error

WriteOne is a convenience function to write a single value to the provided Store. It will create a new Transaction to perform the write with, and clean up after itself should an error occur.

Types

type Context added in v0.12.2

type Context = v1.Context

Context is a simple container for key/value pairs.

func NewContext added in v0.12.2

func NewContext() *Context

NewContext returns a new context object.

type DataEvent added in v0.5.3

type DataEvent = v1.DataEvent

DataEvent describes a change to a base data document.

type Error

type Error = v1.Error

Error is the error type returned by the storage layer.

type Iterator added in v0.42.0

type Iterator = v1.Iterator

Iterator defines the interface that can be used to read files from a directory starting with files at the base of the directory, then sub-directories etc.

type MakeDirer added in v0.39.0

type MakeDirer = v1.MakeDirer

MakeDirer defines the interface a Store could realize to override the generic MakeDir functionality in storage.MakeDir

type PatchOp

type PatchOp = v1.PatchOp

PatchOp is the enumeration of supposed modifications.

type Path added in v0.3.0

type Path = v1.Path

Path refers to a document in storage.

func MustParsePath added in v0.3.0

func MustParsePath(s string) Path

MustParsePath returns a new Path for s. If s cannot be parsed, this function will panic. This is mostly for test purposes.

func NewPathForRef added in v0.3.0

func NewPathForRef(ref ast.Ref) (path Path, err error)

NewPathForRef returns a new path for the given ref.

func ParsePath added in v0.3.0

func ParsePath(str string) (path Path, ok bool)

ParsePath returns a new path for the given str.

func ParsePathEscaped added in v0.8.1

func ParsePathEscaped(str string) (path Path, ok bool)

ParsePathEscaped returns a new path for the given escaped str.

type Policy added in v0.5.0

type Policy = v1.Policy

Policy defines the interface for policy module storage.

type PolicyEvent added in v0.5.3

type PolicyEvent = v1.PolicyEvent

PolicyEvent describes a change to a policy.

type PolicyNotSupported added in v0.5.0

type PolicyNotSupported = v1.PolicyNotSupported

PolicyNotSupported provides a default implementation of the policy interface which may be used if the backend does not support policy storage.

type Store added in v0.2.0

type Store = v1.Store

Store defines the interface for the storage layer's backend.

type Transaction added in v0.2.0

type Transaction = v1.Transaction

Transaction defines the interface that identifies a consistent snapshot over the policy engine's storage layer.

func NewTransactionOrDie added in v0.2.0

func NewTransactionOrDie(ctx context.Context, store Store, params ...TransactionParams) Transaction

NewTransactionOrDie is a helper function to create a new transaction. If the storage layer cannot create a new transaction, this function will panic. This function should only be used for tests.

type TransactionParams added in v0.3.0

type TransactionParams = v1.TransactionParams

TransactionParams describes a new transaction.

type Trigger added in v0.2.0

type Trigger = v1.Trigger

Trigger defines the interface that stores implement to register for change notifications when the store is changed.

type TriggerConfig added in v0.2.0

type TriggerConfig = v1.TriggerConfig

TriggerConfig contains the trigger registration configuration.

type TriggerEvent added in v0.5.0

type TriggerEvent = v1.TriggerEvent

TriggerEvent describes the changes that caused the trigger to be invoked.

type TriggerHandle added in v0.5.3

type TriggerHandle = v1.TriggerHandle

TriggerHandle defines the interface that can be used to unregister triggers that have been registered on a Store.

type TriggersNotSupported added in v0.2.0

type TriggersNotSupported = v1.TriggersNotSupported

TriggersNotSupported provides default implementations of the Trigger interface which may be used if the backend does not support triggers.

type Update added in v0.42.0

type Update = v1.Update

Update contains information about a file

type WritesNotSupported added in v0.2.0

type WritesNotSupported = v1.WritesNotSupported

WritesNotSupported provides a default implementation of the write interface which may be used if the backend does not support writes.

Directories

Path Synopsis
Package disk provides disk-based implementation of the storage.Store interface.
Package disk provides disk-based implementation of the storage.Store interface.
Deprecated: This package is intended for older projects transitioning from OPA v0.x and will remain for the lifetime of OPA v1.x, but its use is not recommended.
Deprecated: This package is intended for older projects transitioning from OPA v0.x and will remain for the lifetime of OPA v1.x, but its use is not recommended.
test
Deprecated: This package is intended for older projects transitioning from OPA v0.x and will remain for the lifetime of OPA v1.x, but its use is not recommended.
Deprecated: This package is intended for older projects transitioning from OPA v0.x and will remain for the lifetime of OPA v1.x, but its use is not recommended.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL