opa: github.com/open-policy-agent/opa/bundle Index | Files

package bundle

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

Package bundle implements bundle loading.

Index

Package Files

bundle.go store.go

Constants

const (
    RegoExt = ".rego"
)

Common file extensions and file names.

func Activate Uses

func Activate(opts *ActivateOpts) error

Activate the bundle(s) by loading into the given Store. This will load policies, data, and record the manifest in storage. The compiler provided will have had the polices compiled on it.

func ActivateLegacy Uses

func ActivateLegacy(opts *ActivateOpts) error

ActivateLegacy calls Activate for the bundles but will also write their manifest to the older unnamed store location. Deprecated: Use Activate with named bundles instead.

func Deactivate Uses

func Deactivate(opts *DeactivateOpts) error

Deactivate the bundle(s). This will erase associated data, policies, and the manifest entry from the store.

func EraseManifestFromStore Uses

func EraseManifestFromStore(ctx context.Context, store storage.Store, txn storage.Transaction, name string) error

EraseManifestFromStore will remove the manifest from storage. This function is called when the bundle is deactivated.

func LegacyEraseManifestFromStore Uses

func LegacyEraseManifestFromStore(ctx context.Context, store storage.Store, txn storage.Transaction) error

LegacyEraseManifestFromStore will erase the bundle manifest from the older single (unnamed) bundle manifest location. Deprecated: Use WriteManifestToStore and named bundles instead.

func LegacyReadRevisionFromStore Uses

func LegacyReadRevisionFromStore(ctx context.Context, store storage.Store, txn storage.Transaction) (string, error)

LegacyReadRevisionFromStore will read the bundle manifest revision from the older single (unnamed) bundle manifest location. Deprecated: Use ReadBundleRevisionFromStore and named bundles instead.

func LegacyWriteManifestToStore Uses

func LegacyWriteManifestToStore(ctx context.Context, store storage.Store, txn storage.Transaction, manifest Manifest) error

LegacyWriteManifestToStore will write the bundle manifest to the older single (unnamed) bundle manifest location. Deprecated: Use WriteManifestToStore and named bundles instead.

func ManifestStoragePath Uses

func ManifestStoragePath(name string) storage.Path

ManifestStoragePath is the storage path used for the given named bundle manifest.

func ReadBundleNamesFromStore Uses

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

ReadBundleNamesFromStore will return a list of bundle names which have had their metadata stored.

func ReadBundleRevisionFromStore Uses

func ReadBundleRevisionFromStore(ctx context.Context, store storage.Store, txn storage.Transaction, name string) (string, error)

ReadBundleRevisionFromStore returns the revision in the specified bundle. If the bundle is not activated, this function will return storage NotFound error.

func ReadBundleRootsFromStore Uses

func ReadBundleRootsFromStore(ctx context.Context, store storage.Store, txn storage.Transaction, name string) ([]string, error)

ReadBundleRootsFromStore returns the roots in the specified bundle. If the bundle is not activated, this function will return storage NotFound error.

func RootPathsOverlap Uses

func RootPathsOverlap(pathA string, pathB string) bool

RootPathsOverlap takes in two bundle root paths and returns true if they overlap.

func Write Uses

func Write(w io.Writer, bundle Bundle) error

Write serializes the Bundle and writes it to w.

func WriteManifestToStore Uses

func WriteManifestToStore(ctx context.Context, store storage.Store, txn storage.Transaction, name string, manifest Manifest) error

WriteManifestToStore will write the manifest into the storage. This function is called when the bundle is activated.

type ActivateOpts Uses

type ActivateOpts struct {
    Ctx          context.Context
    Store        storage.Store
    Txn          storage.Transaction
    Compiler     *ast.Compiler
    Metrics      metrics.Metrics
    Bundles      map[string]*Bundle     // Optional
    ExtraModules map[string]*ast.Module // Optional
    // contains filtered or unexported fields
}

ActivateOpts defines options for the Activate API call.

type Bundle Uses

type Bundle struct {
    Manifest Manifest
    Data     map[string]interface{}
    Modules  []ModuleFile
}

Bundle represents a loaded bundle. The bundle can contain data and policies.

func (Bundle) Equal Uses

func (b Bundle) Equal(other Bundle) bool

Equal returns true if this bundle's contents equal the other bundle's contents.

func (*Bundle) ParsedModules Uses

func (b *Bundle) ParsedModules(bundleName string) map[string]*ast.Module

ParsedModules returns a map of parsed modules with names that are unique and human readable for the given a bundle name.

type DeactivateOpts Uses

type DeactivateOpts struct {
    Ctx         context.Context
    Store       storage.Store
    Txn         storage.Transaction
    BundleNames map[string]struct{}
}

DeactivateOpts defines options for the Deactivate API call

type Manifest Uses

type Manifest struct {
    Revision string    `json:"revision"`
    Roots    *[]string `json:"roots,omitempty"`
}

Manifest represents the manifest from a bundle. The manifest may contain metadata such as the bundle revision.

func (*Manifest) Init Uses

func (m *Manifest) Init()

Init initializes the manifest. If you instantiate a manifest manually, call Init to ensure that the roots are set properly.

type ModuleFile Uses

type ModuleFile struct {
    Path   string
    Raw    []byte
    Parsed *ast.Module
}

ModuleFile represents a single module contained a bundle.

type Reader Uses

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

Reader contains the reader to load the bundle from.

func NewCustomReader Uses

func NewCustomReader(loader file.DirectoryLoader) *Reader

NewCustomReader returns a new Reader configured to use the specified DirectoryLoader.

func NewReader Uses

func NewReader(r io.Reader) *Reader

NewReader returns a new Reader. Deprecated: Use NewCustomReader with TarballLoader instead

func (*Reader) IncludeManifestInData Uses

func (r *Reader) IncludeManifestInData(includeManifestInData bool) *Reader

IncludeManifestInData sets whether the manifest metadata should be included in the bundle's data.

func (*Reader) Read Uses

func (r *Reader) Read() (Bundle, error)

Read returns a new Bundle loaded from the reader.

Package bundle imports 19 packages (graph) and is imported by 22 packages. Updated 2019-10-31. Refresh now. Tools for package owners.