Documentation
¶
Index ¶
- Constants
- Variables
- func Colorize(s string, c Color) string
- func Colorizef(c Color, fmat string, args ...interface{}) string
- func EmojiForLevel(l rules.Level, jurassic bool) string
- func Grade(score int) string
- func Titleize(res string, count int) string
- type Builder
- func (b *Builder) AddError(err error)
- func (b *Builder) AddSection(gvr types.GVR, singular string, o issues.Outcome, t *Tally)
- func (b *Builder) HasContent() bool
- func (b *Builder) PrintClusterInfo(s *ScanReport, metrics bool)
- func (b *Builder) PrintHeader(s *ScanReport)
- func (b *Builder) PrintReport(level rules.Level, s *ScanReport)
- func (b *Builder) PrintSummary(s *ScanReport)
- func (b *Builder) SetClusterContext(cl, ct string)
- func (b *Builder) ToHTML() (string, error)
- func (b *Builder) ToJSON() (string, error)
- func (b *Builder) ToJunit(level rules.Level) (string, error)
- func (b *Builder) ToPrometheus(gtwy *config.PushGateway, instance, ns, asset string, cc rules.Glossary) *push.Pusher
- func (b *Builder) ToScore() (int, error)
- func (b *Builder) ToYAML() (string, error)
- type Color
- type DeltaScore
- type Error
- type Errors
- type Failure
- type Issue
- type Property
- type Report
- type ScanReport
- func (s *ScanReport) Badge(score int) []string
- func (s *ScanReport) Close()
- func (s *ScanReport) Color(msg string, c Color) string
- func (s *ScanReport) Comment(msg string)
- func (s *ScanReport) Dump(l rules.Level, ii issues.Issues)
- func (s *ScanReport) Error(msg string, err error)
- func (s *ScanReport) Open(msg string, t *Tally)
- func (s *ScanReport) Print(l rules.Level, indent int, msg string)
- type Section
- type Sections
- type Tally
- func (t *Tally) Dump(s *ScanReport) string
- func (t *Tally) ErrCount() int
- func (t *Tally) IsValid() bool
- func (t *Tally) MarshalJSON() ([]byte, error)
- func (t *Tally) MarshalYAML() (interface{}, error)
- func (t *Tally) Rollup(o issues.Outcome) *Tally
- func (t *Tally) Score() int
- func (t *Tally) UnmarshalYAML(f func(interface{}) error) error
- func (t *Tally) WarnCount() int
- type TestCase
- type TestSuite
- type TestSuites
Constants ¶
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" )
const ( // FontBold style FontBold = 1 // Width denotes the maximum width of a report. Width = 100 )
Variables ¶
var GraderLogo = []string{
"o .-'-. ",
" o __| K `\\ ",
" o `-,-`--._ `\\",
" [] .->' a `|-'",
" `=/ (__/_ / ",
" \\_, ` _) ",
" `----; | ",
}
GraderLogo affords for replacing logo parts.
var Logo = []string{
"K .-'-. ",
" 8 __| `\\ ",
" s `-,-`--._ `\\",
" [] .->' a `|-'",
" `=/ (__/_ / ",
" \\_, ` _) ",
" `----; | ",
}
Logo popeye
var Popeye = []string{
` ___ ___ _____ _____ `,
`| _ \___| _ \ __\ \ / / __|`,
`| _/ _ \ _/ _| \ V /| _| `,
`|_| \___/_| |___| |_| |___|`,
}
Popeye title
Functions ¶
func EmojiForLevel ¶
EmojiForLevel maps lint levels to emojis.
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 (*Builder) AddSection ¶ added in v0.3.0
AddSection adds a linter section to the report.
func (*Builder) HasContent ¶ added in v0.4.0
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
SetClusterContext sets the current cluster name.
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.
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 (Errors) MarshalYAML ¶ added in v0.20.0
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 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
type ScanReport ¶ added in v0.20.0
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) 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.
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
type Tally ¶
type Tally struct {
// contains filtered or unexported fields
}
Tally tracks lint section scores.
func (*Tally) Dump ¶
func (t *Tally) Dump(s *ScanReport) string
Dump writes out tally and computes length
func (*Tally) MarshalJSON ¶ added in v0.3.0
MarshalJSON renders a tally to JSON.
func (*Tally) MarshalYAML ¶ added in v0.3.0
MarshalYAML renders a tally to YAML.
func (*Tally) UnmarshalYAML ¶ added in v0.4.0
UnmarshalYAML renders a tally to YAML.
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.