popeye: github.com/derailed/popeye/internal/report Index | Files

package report

import "github.com/derailed/popeye/internal/report"


Package Files

builder.go color.go delta_score.go emoji.go grade.go html.go junit.go logo.go prometheus.go tally.go writer.go


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"
const (
    // FontBold style
    FontBold = 1

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


var  = []string{
    "o          .-'-.     ",
    " o     __| K    `\\  ",
    "  o   `-,-`--._   `\\",
    " []  .->'  a     `|-'",
    "  `=/ (__/_       /  ",
    "    \\_,    `    _)  ",
    "       `----;  |     ",

GraderLogo affords for replacing logo parts.

var  = []string{
    "K          .-'-.     ",
    " 8     __|      `\\  ",
    "  s   `-,-`--._   `\\",
    " []  .->'  a     `|-'",
    "  `=/ (__/_       /  ",
    "    \\_,    `    _)  ",
    "       `----;  |     ",

Logo popeye

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

Popeye title

func Colorize Uses

func Colorize(s string, c Color) string

Colorize a string based on given color.

func Colorizef Uses

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

Colorizef colorizes a formatted string.

func EmojiForLevel Uses

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

EmojiForLevel maps lint levels to emojis.

func Grade Uses

func Grade(score int) string

Grade returns a run report grade based on score.

func Titleize Uses

func Titleize(res string, count int) string

Titleize renders a section title.

type Builder Uses

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

Builder represents sanitizer

func NewBuilder Uses

func NewBuilder() *Builder

NewBuilder returns a new instance.

func (*Builder) AddError Uses

func (b *Builder) AddError(err error)

AddError record an error associted with the report.

func (*Builder) AddSection Uses

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 Uses

func (b *Builder) ClusterName() string

ClusterName returns the cluster name.

func (*Builder) HasContent Uses

func (b *Builder) HasContent() bool

HasContent checks if we actually have anything to report.

func (*Builder) PrintClusterInfo Uses

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

PrintClusterInfo displays cluster information.

func (*Builder) PrintHeader Uses

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

PrintHeader prints report header to screen.

func (*Builder) PrintReport Uses

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

PrintReport prints out sanitizer report to screen

func (*Builder) PrintSummary Uses

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

PrintSummary print outs summary report to screen.

func (*Builder) SetClusterName Uses

func (b *Builder) SetClusterName(s string)

SetClusterName sets the current cluster name.

func (*Builder) ToHTML Uses

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

ToHTML dumps sanitizer to HTML.

func (*Builder) ToJSON Uses

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

ToJSON dumps sanitizer to JSON.

func (*Builder) ToJunit Uses

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

ToJunit dumps sanitizer to JUnit.

func (*Builder) ToPrometheus Uses

func (b *Builder) ToPrometheus(address *string, namespace string) *push.Pusher

ToPrometheus returns prometheus pusher.

func (*Builder) ToScore Uses

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

ToScore dumps sanitizer to only the score value.

func (*Builder) ToYAML Uses

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

ToYAML dumps sanitizer to YAML.

type Color Uses

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 Uses

type DeltaScore struct {
    // contains filtered or unexported fields

DeltaScore tracks delta between 2 tally scores.

func NewDeltaScore Uses

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

NewDeltaScore returns a new delta score.

type Error Uses

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 Uses

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 Uses

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 Uses

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

Property represents key/value pair.

type Report Uses

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 Uses

type Sanitizer struct {
    // contains filtered or unexported fields

Sanitizer represents a sanitizer report.

func NewSanitizer Uses

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

NewSanitizer returns a new sanitizer report writer.

func (*Sanitizer) Badge Uses

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

Badge returns a popeye grade.

func (*Sanitizer) Close Uses

func (s *Sanitizer) Close()

Close a report section.

func (*Sanitizer) Color Uses

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

Color or not this message by inject ansi colors.

func (*Sanitizer) Comment Uses

func (s *Sanitizer) Comment(msg string)

Comment writes a comment line.

func (*Sanitizer) Dump Uses

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

Dump all errors to output.

func (*Sanitizer) Error Uses

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

Error prints out error out.

func (*Sanitizer) Open Uses

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

Open begins a new report section.

func (*Sanitizer) Print Uses

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

Print a colorized message.

type Section Uses

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 Uses

type Sections []Section

Sections represents a collection of sections.

func (Sections) Len Uses

func (s Sections) Len() int

Len returns the list size.

func (Sections) Less Uses

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

Less returns true if i < j.

func (Sections) Swap Uses

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

Swap swaps list values.

type Tally Uses

type Tally struct {
    // contains filtered or unexported fields

Tally tracks lint section scores.

func NewTally Uses

func NewTally() *Tally

NewTally returns a new tally.

func (*Tally) Dump Uses

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

Dump writes out tally and computes length

func (*Tally) IsValid Uses

func (t *Tally) IsValid() bool

IsValid checks if tally is valid.

func (*Tally) MarshalJSON Uses

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

MarshalJSON renders a tally to JSON.

func (*Tally) MarshalYAML Uses

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

MarshalYAML renders a tally to YAML.

func (*Tally) Rollup Uses

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

Rollup tallies up the report scores.

func (*Tally) Score Uses

func (t *Tally) Score() int

Score returns the tally computed score.

func (*Tally) UnmarshalYAML Uses

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

UnmarshalYAML renders a tally to YAML.

type TestCase Uses

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 Uses

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 Uses

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.

Package report imports 18 packages (graph) and is imported by 2 packages. Updated 2020-07-09. Refresh now. Tools for package owners.