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

package compile

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

Package compile implements bundles compilation and linking.

Index

Package Files

compile.go

Constants

const (
    // TargetRego is the default target. The source rego is copied (potentially
    // rewritten for optimization purpsoes) into the bundle. The target supports
    // base documents.
    TargetRego = "rego"

    // TargetWasm is an alternative target that compiles the policy into a wasm
    // module instead of Rego. The target supports base documents.
    TargetWasm = "wasm"
)

type Compiler Uses

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

Compiler implements bundle compilation and linking.

func New Uses

func New() *Compiler

New returns a new compiler instance that can be invoked.

func (*Compiler) Build Uses

func (c *Compiler) Build(ctx context.Context) error

Build compiles and links the input files and outputs a bundle to the writer.

func (*Compiler) Bundle Uses

func (c *Compiler) Bundle() *bundle.Bundle

Bundle returns the compiled bundle. This function can be called to retrieve the output of the compiler (as an alternative to having the bundle written to a stream.)

func (*Compiler) Debug Uses

func (c *Compiler) Debug() []Debug

Debug returns a list of debug events produced by the compiler.

func (*Compiler) WithAsBundle Uses

func (c *Compiler) WithAsBundle(enabled bool) *Compiler

WithAsBundle sets file loading mode on the compiler.

func (*Compiler) WithBundle Uses

func (c *Compiler) WithBundle(b *bundle.Bundle) *Compiler

WithBundle sets the input bundle to compile. This should be used as an alternative to reading from paths. This function overrides any file loading options.

func (*Compiler) WithBundleSigningConfig Uses

func (c *Compiler) WithBundleSigningConfig(config *bundle.SigningConfig) *Compiler

WithBundleSigningConfig sets the key configuration to use to generate a signed bundle

func (*Compiler) WithBundleVerificationConfig Uses

func (c *Compiler) WithBundleVerificationConfig(config *bundle.VerificationConfig) *Compiler

WithBundleVerificationConfig sets the key configuration to use to verify a signed bundle

func (*Compiler) WithBundleVerificationKeyID Uses

func (c *Compiler) WithBundleVerificationKeyID(keyID string) *Compiler

WithBundleVerificationKeyID sets the key to use to verify a signed bundle. If provided, the "keyid" claim in the bundle signature, will be set to this value

func (*Compiler) WithCapabilities Uses

func (c *Compiler) WithCapabilities(capabilities *ast.Capabilities) *Compiler

WithCapabilities sets the capabilities to use while checking policies.

func (*Compiler) WithEntrypoints Uses

func (c *Compiler) WithEntrypoints(e ...string) *Compiler

WithEntrypoints sets the policy entrypoints on the compiler. Entrypoints tell the compiler what rules to expect and where optimizations can be targetted. The wasm target requires at least one entrypoint as does optimization.

func (*Compiler) WithFilter Uses

func (c *Compiler) WithFilter(filter loader.Filter) *Compiler

WithFilter sets the loader filter to use when reading non-bundle input files.

func (*Compiler) WithOptimizationLevel Uses

func (c *Compiler) WithOptimizationLevel(n int) *Compiler

WithOptimizationLevel sets the optimization level on the compiler. By default optimizations are disabled. Higher levels apply more aggressive optimizations but can take longer.

func (*Compiler) WithOutput Uses

func (c *Compiler) WithOutput(w io.Writer) *Compiler

WithOutput sets the output stream to write the bundle to.

func (*Compiler) WithPaths Uses

func (c *Compiler) WithPaths(p ...string) *Compiler

WithPaths adds input filepaths to read policy and data from.

func (*Compiler) WithRevision Uses

func (c *Compiler) WithRevision(r string) *Compiler

WithRevision sets the revision to include in the output bundle manifest.

func (*Compiler) WithTarget Uses

func (c *Compiler) WithTarget(t string) *Compiler

WithTarget sets the output target type to use.

type Debug Uses

type Debug struct {
    Location *ast.Location
    Message  string
}

Debug contains debugging information produced by the build about optimizations and other operations.

func (Debug) String Uses

func (d Debug) String() string

Package compile imports 19 packages (graph) and is imported by 2 packages. Updated 2021-01-22. Refresh now. Tools for package owners.