report

package
v0.21.3 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

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

	// JurassicFormat dumps report with dud fancy-ness.
	JurassicFormat = "jurassic"

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

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

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

	// JunitFormat renders report as JUnit.
	JunitFormat = "junit"

	// ScoreFormat renders report as the value of the Score.
	ScoreFormat = "score"

	// PromFormat renders report to prom metrics.
	PromFormat = "prometheus"
)
View Source
const (
	// FontBold style
	FontBold = 1

	// Width denotes the maximum width of a 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 rules.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"`
	ClusterName string
	ContextName string
}

Builder tracks a scan report output.

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 associated with the report.

func (*Builder) AddSection added in v0.3.0

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

AddSection adds a linter section to the report.

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 *ScanReport, metrics bool)

PrintClusterInfo displays cluster information.

func (*Builder) PrintHeader added in v0.3.0

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

PrintHeader prints report header to screen.

func (*Builder) PrintReport added in v0.3.0

func (b *Builder) PrintReport(level rules.Level, s *ScanReport)

PrintReport prints out scan report to screen

func (*Builder) PrintSummary added in v0.3.0

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

PrintSummary print outs summary report to screen.

func (*Builder) SetClusterContext added in v0.20.0

func (b *Builder) SetClusterContext(cl, ct string)

SetClusterContext sets the current cluster name.

func (*Builder) ToHTML added in v0.7.0

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

ToHTML dumps scan to HTML.

func (*Builder) ToJSON added in v0.3.0

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

ToJSON dumps scan to JSON.

func (*Builder) ToJunit added in v0.4.0

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

ToJunit dumps scan to JUnit.

func (*Builder) ToPrometheus added in v0.5.0

func (b *Builder) ToPrometheus(gtwy *config.PushGateway, instance, ns, asset string, cc rules.Glossary) *push.Pusher

ToPrometheus returns prometheus pusher.

func (*Builder) ToScore added in v0.6.2

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

ToScore dumps scan to only the score value.

func (*Builder) ToYAML added in v0.3.0

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

ToYAML dumps scan 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 rules.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 Errors added in v0.20.0

type Errors []error

func (Errors) MarshalJSON added in v0.20.0

func (ee Errors) MarshalJSON() ([]byte, error)

func (Errors) MarshalYAML added in v0.20.0

func (ee Errors) MarshalYAML() (interface{}, 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
	MaxSeverity(string) rules.Level
	Severity() rules.Level
	Description() string
	HasSubIssues() bool
	SubIssues() map[string][]Issue
}

Issue represents a linter issue.

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 {
	Timestamp string   `json:"report_time" yaml:"report_time"`
	Score     int      `json:"score" yaml:"score"`
	Grade     string   `json:"grade" yaml:"grade"`
	Sections  Sections `json:"sections,omitempty" yaml:"sections,omitempty"`
	Errors    Errors   `json:"errors,omitempty" yaml:"errors,omitempty"`
	// contains filtered or unexported fields
}

Report represents a popeye scan report.

func (Report) ListSections added in v0.20.0

func (r Report) ListSections() Sections

type ScanReport added in v0.20.0

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

ScanReport represents a scan report.

func New added in v0.20.0

func New(w io.Writer, jurassic bool) *ScanReport

New returns a new instance.

func (*ScanReport) Badge added in v0.20.0

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

Badge returns a popeye grade.

func (*ScanReport) Close added in v0.20.0

func (s *ScanReport) Close()

Close a report section.

func (*ScanReport) Color added in v0.20.0

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

Color or not this message by inject ansi colors.

func (*ScanReport) Comment added in v0.20.0

func (s *ScanReport) Comment(msg string)

Comment writes a comment line.

func (*ScanReport) Dump added in v0.20.0

func (s *ScanReport) Dump(l rules.Level, ii issues.Issues)

Dump all errors to output.

func (*ScanReport) Error added in v0.20.0

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

Error prints out error out.

func (*ScanReport) Open added in v0.20.0

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

Open begins a new report section.

func (*ScanReport) Print added in v0.20.0

func (s *ScanReport) Print(l rules.Level, indent int, msg string)

Print a colorized message.

type Section added in v0.3.0

type Section struct {
	Title   string         `json:"linter" yaml:"linter"`
	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 linter pass

type Sections added in v0.8.0

type Sections []Section

Sections represents a collection of sections.

func (Sections) CodeTallies added in v0.20.0

func (s Sections) CodeTallies() tally.Linter

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 *ScanReport) 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"`
	Timestamp string   `xml:"report_time,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