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

package loader

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

Package loader contains utilities for loading files into OPA.

Index

Package Files

errors.go loader.go

func AsBundle Uses

func AsBundle(path string) (*bundle.Bundle, error)

AsBundle loads a path as a bundle. If it is a single file it will be treated as a normal tarball bundle. If a directory is supplied it will be loaded as an unzipped bundle tree.

func CleanPath Uses

func CleanPath(path string) string

CleanPath returns the normalized version of a path that can be used as an identifier.

func Paths Uses

func Paths(path string, recurse bool) (paths []string, err error)

Paths returns a sorted list of files contained at path. If recurse is true and path is a directory, then Paths will walk the directory structure recursively and list files at each level.

func SplitPrefix Uses

func SplitPrefix(path string) ([]string, string)

SplitPrefix returns a tuple specifying the document prefix and the file path.

type Errors Uses

type Errors []error

Errors is a wrapper for multiple loader errors.

func (Errors) Error Uses

func (e Errors) Error() string

type Filter Uses

type Filter func(abspath string, info os.FileInfo, depth int) bool

Filter defines the interface for filtering files during loading. If the filter returns true, the file should be excluded from the result.

func GlobExcludeName Uses

func GlobExcludeName(pattern string, minDepth int) Filter

GlobExcludeName excludes files and directories whose names do not match the shell style pattern at minDepth or greater.

type RegoFile Uses

type RegoFile struct {
    Name   string
    Parsed *ast.Module
    Raw    []byte
}

RegoFile represents the result of loading a single Rego source file.

func Rego Uses

func Rego(path string) (*RegoFile, error)

Rego returns a RegoFile object loaded from the given path.

type Result Uses

type Result struct {
    Documents map[string]interface{}
    Modules   map[string]*RegoFile
    // contains filtered or unexported fields
}

Result represents the result of successfully loading zero or more files.

func All Uses

func All(paths []string) (*Result, error)

All returns a Result object loaded (recursively) from the specified paths.

func AllRegos Uses

func AllRegos(paths []string) (*Result, error)

AllRegos returns a Result object loaded (recursively) with all Rego source files from the specified paths.

func Filtered Uses

func Filtered(paths []string, filter Filter) (*Result, error)

Filtered returns a Result object loaded (recursively) from the specified paths while applying the given filters. If any filter returns true, the file/directory is excluded.

func (*Result) Compiler Uses

func (l *Result) Compiler() (*ast.Compiler, error)

Compiler returns a Compiler object with the compiled modules from this loader result.

func (*Result) ParsedModules Uses

func (l *Result) ParsedModules() map[string]*ast.Module

ParsedModules returns the parsed modules stored on the result.

func (*Result) Store Uses

func (l *Result) Store() (storage.Store, error)

Store returns a Store object with the documents from this loader result.

Package loader imports 15 packages (graph) and is imported by 22 packages. Updated 2019-11-15. Refresh now. Tools for package owners.