package loader

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

Package loader contains utilities for loading files into OPA.

Index

Constants

const RegoExt = ".rego"

RegoExt declares the standard extension for Rego source files.

Functions

func CleanPath

func CleanPath(path string) string

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

func Paths

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

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

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

Types

type RegoFile

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

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

func Rego

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

Rego returns a RegoFile object loaded from the given path.

type Result

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

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

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

func AllRegos

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

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

Source Files

errors.go loader.go merge.go

Version
v0.5.10
Published
Oct 30, 2017
Platform
darwin/amd64
Imports
10 packages
Last checked
27 seconds ago

Tools for package owners.