report

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2019 License: Apache-2.0 Imports: 14 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"
)
View Source
const (
	// FontBold style
	FontBold = 1

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

Variables

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 Grade

func Grade(score int) string

Grade returns a run report grade based on score.

func Titleize added in v0.3.0

func Titleize(r string) string

Titleize returns a human readable resource name.

Types

type Builder added in v0.3.0

type Builder struct {
	Report Report `json:"popeye" yaml:"popeye"`
}

Builder represents sanitizer

func NewBuilder added in v0.3.0

func NewBuilder() *Builder

NewBuilder returns a new sanitizer report.

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(name string, issues linter.Issues, t *Tally)

AddSection adds a sanitizer section to the report.

func (*Builder) ClusterInfo added in v0.3.0

func (b *Builder) ClusterInfo(s *Sanitizer, l linter.Loader)

ClusterInfo dumps cluster information to screen.

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 linter.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) ToJSON added in v0.3.0

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

ToJSON dumps sanitizer to JSON.

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 (
	ColorOrangish  Color = 220
	ColorOrange    Color = 208
	ColorGray      Color = 250
	ColorWhite     Color = 15
	ColorBlue      Color = 105
	ColorRed       Color = 196
	ColorCoolBlue  Color = 99
	ColorAqua      Color = 122
	ColorDarkOlive Color = 155
	ColorLighSlate Color = 75
	ColorYellow    Color = 226
	ColorYellow2   Color = 190
	ColorGreenPale Color = 114
	ColorGreen     Color = 82
)

Color ANSI palette (256!)

type Report added in v0.3.0

type Report struct {
	Score    int       `json:"score" yaml:"score"`
	Grade    string    `json:"grade" yaml:"grade"`
	Sections []Section `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, fd uintptr, 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 linter.Level, issues ...linter.Issue)

Dump all errors to output.

func (*Sanitizer) EmojiForLevel added in v0.2.0

func (s *Sanitizer) EmojiForLevel(l linter.Level) string

EmojiForLevel maps lint levels to emojis.

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 linter.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"`
	Tally  *Tally        `json:"tally" yaml:"tally"`
	Issues linter.Issues `json:"issues,omitempty" yaml:"issues,omitempty"`
}

Section represents a sanitizer pass

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) 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(run linter.Issues) *Tally

Rollup tallies up the report scores.

func (*Tally) Score

func (t *Tally) Score() int

Score returns the tally computed score.

Jump to

Keyboard shortcuts

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