report

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultFormat dumps sanitizer with color, emojis, the works.
	DefaultFormat = "standard"

	// JurassicFormat dumps sanitizer with 0 fancyness.
	JurassicFormat = "jurassic"

	// YAMLFormat dumps sanitizer as YAML.
	YAMLFormat = "yaml"

	// JSONFormat dumps sanitizer as JSON.
	JSONFormat = "json"

	// HTMLFormat dumps sanitizer as HTML
	HTMLFormat = "html"

	// JunitFormat dumps sanitizer as JUnit report.
	JunitFormat = "junit"

	// PrometheusFormat pushes sanitizer as Prometheus metrics.
	PrometheusFormat = "prometheus"

	// ScoreFormat pushes sanitizer as the value of the Score.
	ScoreFormat = "score"
)
View Source
const (
	// FontBold style
	FontBold = 1

	// Width denotes the maximum width of the sanitizer report.
	Width = 100
)

Variables

View Source
	"o          .-'-.     ",
	" o     __| K    `\\  ",
	"  o   `-,-`--._   `\\",
	" []  .->'  a     `|-'",
	"  `=/ (__/_       /  ",
	"    \\_,    `    _)  ",
	"       `----;  |     ",
}

GraderLogo affords for replacing logo parts.

View Source
	"K          .-'-.     ",
	" 8     __|      `\\  ",
	"  s   `-,-`--._   `\\",
	" []  .->'  a     `|-'",
	"  `=/ (__/_       /  ",
	"    \\_,    `    _)  ",
	"       `----;  |     ",
}

Logo popeye

View Source
var Popeye = []string{
	` ___     ___ _____   _____ `,
	`| _ \___| _ \ __\ \ / / __|`,
	`|  _/ _ \  _/ _| \ V /| _| `,
	`|_| \___/_| |___| |_| |___|`,
}

Popeye title

Functions

func Colorize

func Colorize(s string, c Color) string

Colorize a string based on given color.

func Colorizef added in v0.4.0

func Colorizef(c Color, fmat string, args ...interface{}) string

Colorizef colorizes a formatted string.

func EmojiForLevel

func EmojiForLevel(l config.Level, jurassic bool) string

EmojiForLevel maps lint levels to emojis.

func Grade

func Grade(score int) string

Grade returns a run report grade based on score.

func Titleize added in v0.3.0

func Titleize(res string, count int) string

Titleize renders a section title.

Types

type Builder added in v0.3.0

type Builder struct {
	Report Report `json:"popeye" yaml:"popeye"`
	// contains filtered or unexported fields
}

Builder represents sanitizer

func NewBuilder added in v0.3.0

func NewBuilder() *Builder

NewBuilder returns a new instance.

func (*Builder) AddError added in v0.3.0

func (b *Builder) AddError(err error)

AddError record an error associted with the report.

func (*Builder) AddSection added in v0.3.0

func (b *Builder) AddSection(gvr client.GVR, singular string, o issues.Outcome, t *Tally)

AddSection adds a sanitizer section to the report.

func (*Builder) ClusterName added in v0.7.0

func (b *Builder) ClusterName() string

ClusterName returns the cluster name.

func (*Builder) HasContent added in v0.4.0

func (b *Builder) HasContent() bool

HasContent checks if we actually have anything to report.

func (*Builder) PrintClusterInfo added in v0.3.6

func (b *Builder) PrintClusterInfo(s *Sanitizer, clusterName string, metrics bool)

PrintClusterInfo displays cluster information.

func (*Builder) PrintHeader added in v0.3.0

func (b *Builder) PrintHeader(s *Sanitizer)

PrintHeader prints report header to screen.

func (*Builder) PrintReport added in v0.3.0

func (b *Builder) PrintReport(level config.Level, s *Sanitizer)

PrintReport prints out sanitizer report to screen

func (*Builder) PrintSummary added in v0.3.0

func (b *Builder) PrintSummary(s *Sanitizer)

PrintSummary print outs summary report to screen.

func (*Builder) SetClusterName added in v0.7.0

func (b *Builder) SetClusterName(s string)

SetClusterName sets the current cluster name.

func (*Builder) ToHTML added in v0.7.0

func (b *Builder) ToHTML() (string, error)

ToHTML dumps sanitizer to HTML.

func (*Builder) ToJSON added in v0.3.0

func (b *Builder) ToJSON() (string, error)

ToJSON dumps sanitizer to JSON.

func (*Builder) ToJunit added in v0.4.0

func (b *Builder) ToJunit(level config.Level) (string, error)

ToJunit dumps sanitizer to JUnit.

func (*Builder) ToPrometheus added in v0.5.0

func (b *Builder) ToPrometheus(gtwy *config.PushGateway, namespace string) *push.Pusher

ToPrometheus returns prometheus pusher.

func (*Builder) ToScore added in v0.6.2

func (b *Builder) ToScore() (int, error)

ToScore dumps sanitizer to only the score value.

func (*Builder) ToYAML added in v0.3.0

func (b *Builder) ToYAML() (string, error)

ToYAML dumps sanitizer to YAML.

type Color

type Color int

Color tracks the output color.

const (
	ColorWhite     Color = 15
	ColorLighSlate Color = 75
	ColorGreen     Color = 82
	ColorCoolBlue  Color = 99
	ColorBlue      Color = 105
	ColorGreenPale Color = 114
	ColorAqua      Color = 122
	ColorDarkOlive Color = 155
	ColorYellow2   Color = 190
	ColorRed       Color = 196
	ColorOrangRed  Color = 202
	ColorOrange    Color = 208
	ColorOrangish  Color = 220
	ColorYellow    Color = 226
	ColorGray      Color = 250
)

Color ANSI palette (256!)

type DeltaScore added in v0.4.0

type DeltaScore struct {
	// contains filtered or unexported fields
}

DeltaScore tracks delta between 2 tally scores.

func NewDeltaScore added in v0.4.0

func NewDeltaScore(level config.Level, s1, s2 int, inverse bool) DeltaScore

NewDeltaScore returns a new delta score.

type Error

type Error struct {
	XMLName xml.Name `xml:"error"`
	Message string   `xml:"message,attr"`
	Type    string   `xml:"type,attr"`
}

Error represents a test error..

type Failure added in v0.4.0

type Failure struct {
	XMLName xml.Name `xml:"failure"`
	Message string   `xml:"message,attr"`
	Type    string   `xml:"type,attr"`
}

Failure represents a test failure.

type Issue added in v0.3.4

type Issue interface {
	MaxSeverity(string) config.Level
	Severity() config.Level
	Description() string
	HasSubIssues() bool
	SubIssues() map[string][]Issue
}

Issue represents a sanitizer issues.

type Property added in v0.4.0

type Property struct {
	Name  string `xml:"name,attr"`
	Value string `xml:"value,attr"`
}

Property represents key/value pair.

type Report added in v0.3.0

type Report struct {
	Score    int      `json:"score" yaml:"score"`
	Grade    string   `json:"grade" yaml:"grade"`
	Sections Sections `json:"sanitizers,omitempty" yaml:"sanitizers,omitempty"`
	Errors   []error  `json:"errors,omitempty" yaml:"errors,omitempty"`
	// contains filtered or unexported fields
}

Report represents the output of a sanitization pass.

type Sanitizer added in v0.2.0

type Sanitizer struct {
	io.Writer
	// contains filtered or unexported fields
}

Sanitizer represents a sanitizer report.

func NewSanitizer added in v0.2.0

func NewSanitizer(w io.Writer, jurassic bool) *Sanitizer

NewSanitizer returns a new sanitizer report writer.

func (*Sanitizer) Badge added in v0.2.0

func (s *Sanitizer) Badge(score int) []string

Badge returns a popeye grade.

func (*Sanitizer) Close added in v0.2.0

func (s *Sanitizer) Close()

Close a report section.

func (*Sanitizer) Color added in v0.2.0

func (s *Sanitizer) Color(msg string, c Color) string

Color or not this message by inject ansi colors.

func (*Sanitizer) Comment added in v0.2.0

func (s *Sanitizer) Comment(msg string)

Comment writes a comment line.

func (*Sanitizer) Dump added in v0.2.0

func (s *Sanitizer) Dump(l config.Level, ii issues.Issues)

Dump all errors to output.

func (*Sanitizer) Error added in v0.2.0

func (s *Sanitizer) Error(msg string, err error)

Error prints out error out.

func (*Sanitizer) Open added in v0.2.0

func (s *Sanitizer) Open(msg string, t *Tally)

Open begins a new report section.

func (*Sanitizer) Print added in v0.2.0

func (s *Sanitizer) Print(l config.Level, indent int, msg string)

Print a colorized message.

type Section added in v0.3.0

type Section struct {
	Title   string         `json:"sanitizer" yaml:"sanitizer"`
	GVR     string         `json:"gvr" yaml:"gvr"`
	Tally   *Tally         `json:"tally" yaml:"tally"`
	Outcome issues.Outcome `json:"issues,omitempty" yaml:"issues,omitempty"`
	// contains filtered or unexported fields
}

Section represents a sanitizer pass

type Sections added in v0.8.0

type Sections []Section

Sections represents a collection of sections.

func (Sections) Len added in v0.8.0

func (s Sections) Len() int

Len returns the list size.

func (Sections) Less added in v0.8.0

func (s Sections) Less(i, j int) bool

Less returns true if i < j.

func (Sections) Swap added in v0.8.0

func (s Sections) Swap(i, j int)

Swap swaps list values.

type Tally

type Tally struct {
	// contains filtered or unexported fields
}

Tally tracks lint section scores.

func NewTally

func NewTally() *Tally

NewTally returns a new tally.

func (*Tally) Dump

func (t *Tally) Dump(s *Sanitizer) string

Dump writes out tally and computes length

func (*Tally) ErrCount added in v0.8.9

func (t *Tally) ErrCount() int

ErrCount returns the number of errors found.

func (*Tally) IsValid

func (t *Tally) IsValid() bool

IsValid checks if tally is valid.

func (*Tally) MarshalJSON added in v0.3.0

func (t *Tally) MarshalJSON() ([]byte, error)

MarshalJSON renders a tally to JSON.

func (*Tally) MarshalYAML added in v0.3.0

func (t *Tally) MarshalYAML() (interface{}, error)

MarshalYAML renders a tally to YAML.

func (*Tally) Rollup

func (t *Tally) Rollup(o issues.Outcome) *Tally

Rollup tallies up the report scores.

func (*Tally) Score

func (t *Tally) Score() int

Score returns the tally computed score.

func (*Tally) UnmarshalYAML added in v0.4.0

func (t *Tally) UnmarshalYAML(f func(interface{}) error) error

UnmarshalYAML renders a tally to YAML.

func (*Tally) WarnCount added in v0.8.9

func (t *Tally) WarnCount() int

WarnCount returns the number of warnings found.

type TestCase added in v0.4.0

type TestCase struct {
	XMLName   xml.Name `xml:"testcase"`
	Classname string   `xml:"classname,attr"`
	Name      string   `xml:"name,attr"`
	Failures  []Failure
	Errors    []Error
}

TestCase represents a sing junit test.

type TestSuite added in v0.4.0

type TestSuite struct {
	XMLName    xml.Name   `xml:"testsuite"`
	Name       string     `xml:"name,attr"`
	Tests      int        `xml:"tests,attr"`
	Failures   int        `xml:"failures,attr"`
	Errors     int        `xml:"errors,attr"`
	Properties []Property `xml:"properties>property,omitempty"`
	TestCases  []TestCase
}

TestSuite represents a collection of tests

type TestSuites added in v0.4.0

type TestSuites struct {
	XMLName  xml.Name `xml:"testsuites"`
	Name     string   `xml:"name,attr"`
	Tests    int      `xml:"tests,attr"`
	Failures int      `xml:"failures,attr"`
	Errors   int      `xml:"errors,attr"`
	Suites   []TestSuite
}

TestSuites a collection of junit test suites.

Jump to

Keyboard shortcuts

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