Documentation ¶
Overview ¶
Package compile implements bundles compilation and linking.
Index ¶
- Constants
- Variables
- type Compiler
- func (c *Compiler) Build(ctx context.Context) error
- func (c *Compiler) Bundle() *bundle.Bundle
- func (c *Compiler) WithAsBundle(enabled bool) *Compiler
- func (c *Compiler) WithBundle(b *bundle.Bundle) *Compiler
- func (c *Compiler) WithBundleSigningConfig(config *bundle.SigningConfig) *Compiler
- func (c *Compiler) WithBundleVerificationConfig(config *bundle.VerificationConfig) *Compiler
- func (c *Compiler) WithBundleVerificationKeyID(keyID string) *Compiler
- func (c *Compiler) WithCapabilities(capabilities *ast.Capabilities) *Compiler
- func (c *Compiler) WithDebug(sink io.Writer) *Compiler
- func (c *Compiler) WithEnablePrintStatements(yes bool) *Compiler
- func (c *Compiler) WithEntrypoints(e ...string) *Compiler
- func (c *Compiler) WithFS(fsys fs.FS) *Compiler
- func (c *Compiler) WithFilter(filter loader.Filter) *Compiler
- func (c *Compiler) WithFollowSymlinks(yes bool) *Compiler
- func (c *Compiler) WithMetadata(metadata *map[string]interface{}) *Compiler
- func (c *Compiler) WithOptimizationLevel(n int) *Compiler
- func (c *Compiler) WithOutput(w io.Writer) *Compiler
- func (c *Compiler) WithPartialNamespace(ns string) *Compiler
- func (c *Compiler) WithPaths(p ...string) *Compiler
- func (c *Compiler) WithPruneUnused(enabled bool) *Compiler
- func (c *Compiler) WithRegoAnnotationEntrypoints(enabled bool) *Compiler
- func (c *Compiler) WithRegoVersion(v ast.RegoVersion) *Compiler
- func (c *Compiler) WithRevision(r string) *Compiler
- func (c *Compiler) WithRoots(r ...string) *Compiler
- func (c *Compiler) WithTarget(t string) *Compiler
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" // TargetPlan is an altertive target that compiles the policy into an // imperative query plan that can be further transpiled or interpreted. TargetPlan = "plan" )
Variables ¶
var Targets = []string{ TargetRego, TargetWasm, TargetPlan, }
Targets contains the list of targets supported by the compiler.
Functions ¶
This section is empty.
Types ¶
type Compiler ¶
type Compiler struct {
// contains filtered or unexported fields
}
Compiler implements bundle compilation and linking.
func (*Compiler) Build ¶
Build compiles and links the input files and outputs a bundle to the writer.
func (*Compiler) 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) WithAsBundle ¶
WithAsBundle sets file loading mode on the compiler.
func (*Compiler) WithBundle ¶
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 ¶
func (c *Compiler) WithBundleSigningConfig(config *bundle.SigningConfig) *Compiler
WithBundleSigningConfig sets the key configuration to use to generate a signed bundle
func (*Compiler) WithBundleVerificationConfig ¶
func (c *Compiler) WithBundleVerificationConfig(config *bundle.VerificationConfig) *Compiler
WithBundleVerificationConfig sets the key configuration to use to verify a signed bundle
func (*Compiler) WithBundleVerificationKeyID ¶
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 ¶
func (c *Compiler) WithCapabilities(capabilities *ast.Capabilities) *Compiler
WithCapabilities sets the capabilities to use while checking policies.
func (*Compiler) WithEnablePrintStatements ¶
WithEnablePrintStatements enables print statements inside of modules compiled by the compiler. If print statements are not enabled, calls to print() are erased at compile-time.
func (*Compiler) WithEntrypoints ¶
WithEntrypoints sets the policy entrypoints on the compiler. Entrypoints tell the compiler what rules to expect and where optimizations can be targeted. 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) WithFollowSymlinks ¶
WithFollowSymlinks sets whether or not to follow symlinks in the bundle directory when building the bundle
func (*Compiler) WithMetadata ¶
WithMetadata sets the additional data to be included in .manifest
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.
func (*Compiler) WithOutput ¶
WithOutput sets the output stream to write the bundle to.
func (*Compiler) WithPartialNamespace ¶
WithPartialNamespace sets the namespace to use for partial evaluation results
func (*Compiler) WithPruneUnused ¶
WithPruneUnused will make rules be ignored that are defined on the same package as the entrypoint, but that are not in the entrypoint set.
Notably this includes functions (they can't be entrypoints) and causes the built bundle to no longer be semantically equivalent to the bundle built without wasm.
This affects the 'wasm' and 'plan' targets only. It has no effect on building 'rego' bundles, i.e., "ordinary bundles".
func (*Compiler) WithRegoAnnotationEntrypoints ¶
WithRegoAnnotationEntrypoints allows the compiler to late-bind entrypoints, based on Rego entrypoint annotations. The rules tagged with entrypoint annotations are added to the global list of entrypoints before optimizations/target compilation.
func (*Compiler) WithRegoVersion ¶
func (c *Compiler) WithRegoVersion(v ast.RegoVersion) *Compiler
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.