package compile
import "github.com/open-policy-agent/opa/compile"
Package compile implements bundles compilation and linking.
Index ¶
- Constants
- type Compiler
- func New() *Compiler
- func (c *Compiler) Build(ctx context.Context) error
- func (c *Compiler) Debug() []Debug
- func (c *Compiler) WithAsBundle(enabled bool) *Compiler
- func (c *Compiler) WithEntrypoints(e ...string) *Compiler
- func (c *Compiler) WithFilter(filter loader.Filter) *Compiler
- func (c *Compiler) WithOptimizationLevel(n int) *Compiler
- func (c *Compiler) WithOutput(w io.Writer) *Compiler
- func (c *Compiler) WithPaths(p ...string) *Compiler
- func (c *Compiler) WithRevision(r string) *Compiler
- func (c *Compiler) WithTarget(t string) *Compiler
- type Debug
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" )
Types ¶
type Compiler ¶
type Compiler struct {
// contains filtered or unexported fields
}
Compiler implements bundle compilation and linking.
func New ¶
func New() *Compiler
New returns a new compiler instance that can be invoked.
func (*Compiler) Build ¶
Build compiles and links the input files and outputs a bundle to the writer.
func (*Compiler) Debug ¶
Debug returns a list of debug events produced by the compiler.
func (*Compiler) WithAsBundle ¶
WithAsBundle sets file loading mode on the compiler.
func (*Compiler) WithEntrypoints ¶
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 ¶
WithFilter sets the loader filter to use when reading non-bundle input files.
func (*Compiler) WithOptimizationLevel ¶
WithOptimizationLevel sets the optimization level on the compiler. By default optimizations are disabled. Higher levels apply more aggressive optimizations but can take longer. Currently only two levels are supported: 0 (disabled) and 1 (enabled).
func (*Compiler) WithOutput ¶
WithOutput sets the output stream to write the bundle to.
func (*Compiler) WithPaths ¶
WithPaths adds input filepaths to read policy and data from.
func (*Compiler) WithRevision ¶
WithRevision sets the revision to include in the output bundle manifest.
func (*Compiler) WithTarget ¶
WithTarget sets the output target type to use.
type Debug ¶
Debug contains debugging information produced by the build about optimizations and other operations.
func (Debug) String ¶
Source Files ¶
- Version
- v0.20.4
- Published
- May 22, 2020
- Platform
- js/wasm
- Imports
- 14 packages
- Last checked
- 27 seconds ago –
Tools for package owners.