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

package presentation

import "github.com/open-policy-agent/opa/internal/presentation"

Package presentation prints results of an expression evaluation in json and tabular formats.


Package Files



var DefaultProfileSortOrder = []string{"total_time_ns", "num_eval", "num_redo", "file", "line"}

DefaultProfileSortOrder is the default ordering unless something is specified in the CLI

func Bindings Uses

func Bindings(w io.Writer, r Output) error

Bindings prints the bindings from r to w.

func JSON Uses

func JSON(w io.Writer, x interface{}) error

JSON writes x to w with indentation.

func Pretty Uses

func Pretty(w io.Writer, r Output) error

Pretty prints all of r to w in a human-readable format.

func Source Uses

func Source(w io.Writer, r Output) error

Source prints partial evaluation results in r to w in a source file friendly format.

func Values Uses

func Values(w io.Writer, r Output) error

Values prints the values from r to w.

type DepAnalysisOutput Uses

type DepAnalysisOutput struct {
    Base    []ast.Ref `json:"base,omitempty"`
    Virtual []ast.Ref `json:"virtual,omitempty"`

DepAnalysisOutput contains the result of dependency analysis to be presented.

func (DepAnalysisOutput) JSON Uses

func (o DepAnalysisOutput) JSON(w io.Writer) error

JSON outputs o to w as JSON.

func (DepAnalysisOutput) Pretty Uses

func (o DepAnalysisOutput) Pretty(w io.Writer) error

Pretty outputs o to w in a human-readable format.

type Output Uses

type Output struct {
    Errors      OutputErrors         `json:"errors,omitempty"`
    Result      rego.ResultSet       `json:"result,omitempty"`
    Partial     *rego.PartialQueries `json:"partial,omitempty"`
    Metrics     metrics.Metrics      `json:"metrics,omitempty"`
    Explanation []*topdown.Event     `json:"explanation,omitempty"`
    Profile     []profiler.ExprStats `json:"profile,omitempty"`
    Coverage    *cover.Report        `json:"coverage,omitempty"`
    // contains filtered or unexported fields

Output contains the result of evaluation to be presented.

func (Output) WithLimit Uses

func (e Output) WithLimit(n int) Output

WithLimit sets the output limit to set on stringified values.

type OutputError Uses

type OutputError struct {
    Message  string      `json:"message"`
    Code     string      `json:"code,omitempty"`
    Location interface{} `json:"location,omitempty"`
    Details  interface{} `json:"details,omitempty"`
    // contains filtered or unexported fields

OutputError provides a common structure for all OPA library errors so that the JSON output given by the presentation package is consistent and parsable.

func NewOutputErrors Uses

func NewOutputErrors(err error) []OutputError

NewOutputErrors creates a new slice of OutputError's based on the type of error passed in. Known structured types will be translated as appropriate, while unknown errors are placed into a structured format with their string value.

func (OutputError) Error Uses

func (j OutputError) Error() string

type OutputErrors Uses

type OutputErrors []OutputError

OutputErrors is a list of errors encountered which are to presented.

func (OutputErrors) Error Uses

func (e OutputErrors) Error() string

Package presentation imports 18 packages (graph) and is imported by 6 packages. Updated 2020-04-05. Refresh now. Tools for package owners.