report

package
v0.0.0-...-685dc72 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2023 License: Apache-2.0 Imports: 3 Imported by: 68

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	// Kind is the severity of the message.
	Kind    EntryKind
	Message string

	// Context is the logical location of the error.
	Context path.ContextPath

	// Marker is the literal location in a json or yaml blob of the error.
	Marker tree.Marker
}

Entry represents one error or message from validation.

func (Entry) String

func (e Entry) String() string

type EntryKind

type EntryKind interface {
	String() string
	IsFatal() bool
}

EntryKind represents an Entry's severity.

type Kind

type Kind int

Kind is a default set of EntryKind.

const (
	Error Kind = iota
	Warn  Kind = iota
	Info  Kind = iota
)

func (Kind) IsFatal

func (k Kind) IsFatal() bool

func (Kind) String

func (k Kind) String() string

type Report

type Report struct {
	Entries []Entry
}

Report is a collection of information from validating a struct.

func (*Report) AddOn

func (r *Report) AddOn(c path.ContextPath, err error, k EntryKind)

func (*Report) AddOnError

func (r *Report) AddOnError(c path.ContextPath, err error)

AddOnError adds err to report with kind "Error" if err is not nil.

func (*Report) AddOnInfo

func (r *Report) AddOnInfo(c path.ContextPath, err error)

AddOnInfo adds err to report with kind "Info" if err is not nil.

func (*Report) AddOnWarn

func (r *Report) AddOnWarn(c path.ContextPath, err error)

AddOnWarn adds err to report with kind "Warning" if err is not nil.

func (*Report) Correlate

func (r *Report) Correlate(n tree.Node)

Correlate takes a node tree and populates the markers in the report's entries based on the entries' context.

func (Report) IsFatal

func (r Report) IsFatal() bool

IsFatal returns true if any entries are fatal.

func (*Report) Merge

func (r *Report) Merge(child Report)

Merge adds the entries from child to r.

func (Report) String

func (r Report) String() string

Jump to

Keyboard shortcuts

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