output

package
v0.22.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2020 License: Apache-2.0 Imports: 11 Imported by: 3

Documentation

Index

Constants

View Source
const (
	OutputStandard = "stdout"
	OutputJSON     = "json"
	OutputTAP      = "tap"
	OutputTable    = "table"
	OutputJUnit    = "junit"
)

The defined output formats represent all of the supported formats that can be used to format and render results.

Variables

This section is empty.

Functions

func ExitCode added in v0.22.0

func ExitCode(results []CheckResult) int

ExitCode returns the exit code that should be returned given all of the returned results.

func ExitCodeFailOnWarn added in v0.22.0

func ExitCodeFailOnWarn(results []CheckResult) int

ExitCodeFailOnWarn returns the exit code that should be returned given all of the returned results, and will consider warnings as failures.

func Outputs added in v0.22.0

func Outputs() []string

Outputs returns the available output formats.

Types

type CheckResult

type CheckResult struct {
	FileName   string        `json:"filename"`
	Namespace  string        `json:"namespace"`
	Successes  int           `json:"successes"`
	Warnings   []Result      `json:"warnings,omitempty"`
	Failures   []Result      `json:"failures,omitempty"`
	Exceptions []Result      `json:"exceptions,omitempty"`
	Queries    []QueryResult `json:"queries,omitempty"`
}

CheckResult describes the result of a conftest policy evaluation. Errors produced by rego should be considered separate from other classes of exceptions.

type JSON added in v0.22.0

type JSON struct {
	Writer io.Writer
}

JSON represents an Outputter that outputs results in JSON format.

func NewJSON added in v0.22.0

func NewJSON(w io.Writer) *JSON

NewJSON creates a new JSON with the given writer.

func (*JSON) Output added in v0.22.0

func (j *JSON) Output(results []CheckResult) error

Output outputs the results.

type JUnit added in v0.22.0

type JUnit struct {
	Writer io.Writer
}

JUnit represents an Outputter that outputs results in JUnit format.

func NewJUnit added in v0.22.0

func NewJUnit(w io.Writer) *JUnit

NewJUnit creates a new JUnit with the given writer.

func (*JUnit) Output added in v0.22.0

func (j *JUnit) Output(results []CheckResult) error

Output outputs the results.

type Options added in v0.22.0

type Options struct {
	Tracing bool
	NoColor bool
}

Options represents the options available when configuring an Outputter.

type Outputter added in v0.22.0

type Outputter interface {
	Output([]CheckResult) error
}

Outputter controls how results of an evaluation will be recorded and reported to the end user.

func Get added in v0.22.0

func Get(format string, options Options) Outputter

Get returns a type that can render output in the given format.

type QueryResult added in v0.22.0

type QueryResult struct {

	// Query is the fully qualified query that was used
	// to determine the result. Ex: (data.main.deny)
	Query string `json:"query"`

	// Results are the individual results of the query.
	// When querying data.main.deny, multiple deny rules can
	// exist, producing multiple results.
	Results []Result `json:"results"`

	// Traces represents a single trace of how the query was
	// evaluated. Each trace value is a trace line.
	Traces []string `json:"traces"`
}

QueryResult describes the result of evaluting a query.

func (QueryResult) Passed added in v0.22.0

func (q QueryResult) Passed() bool

Passed returns true if all of the results in the query passed and no failures were found.

type Result

type Result struct {
	Message  string                 `json:"msg"`
	Metadata map[string]interface{} `json:"metadata,omitempty"`
}

Result describes the result of a single rule evaluation.

func NewResult

func NewResult(metadata map[string]interface{}) (Result, error)

NewResult creates a new result. An error is returned if the metadata could not be successfully parsed.

func (Result) Passed added in v0.22.0

func (r Result) Passed() bool

Passed returns true if the result did not fail a policy.

type Standard added in v0.22.0

type Standard struct {
	Writer io.Writer

	// Tracing will render the trace results of the
	// queries when set to true.
	Tracing bool

	// NoColor will disable all coloring when
	// set to true.
	NoColor bool
}

Standard represents an Outputter that outputs results in a human readable format.

func NewStandard added in v0.22.0

func NewStandard(w io.Writer) *Standard

NewStandard creates a new Standard with the given writer.

func (*Standard) Output added in v0.22.0

func (s *Standard) Output(results []CheckResult) error

Output outputs the results.

type TAP added in v0.22.0

type TAP struct {
	Writer io.Writer
}

TAP represents an Outputter that outputs results in TAP format.

func NewTAP added in v0.22.0

func NewTAP(w io.Writer) *TAP

NewTAP creates a new TAP with the given writer.

func (*TAP) Output added in v0.22.0

func (t *TAP) Output(checkResults []CheckResult) error

Output outputs the results.

type Table added in v0.22.0

type Table struct {
	Writer io.Writer
}

Table represents an Outputter that outputs results in a tabular format.

func NewTable added in v0.22.0

func NewTable(w io.Writer) *Table

NewTable creates a new Table with the given writer.

func (*Table) Output added in v0.22.0

func (t *Table) Output(checkResults []CheckResult) error

Output outputs the results.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL