Documentation
¶
Overview ¶
Package output owns serialization and terminal presentation of prepared values.
Index ¶
- Constants
- func Bold(s string, color bool) string
- func ColorEnabled(w io.Writer) bool
- func Cyan(s string, color bool) string
- func Dim(s string, color bool) string
- func Document(blocks ...string) string
- func Elapsed(d time.Duration) string
- func Fail(s string, color bool) string
- func LineSubjects(changes []LineChange, format Format) []manifest.NamedResource
- func MessageTail(message string, paint func(string, bool) string, color bool) string
- func NameLines(changes []LineChange, names Names)
- func Pass(s string, color bool) string
- func Truncate(s string, width int) string
- func Verdict(color bool, glyph string, elapsed time.Duration, counts ...Count) string
- func Warn(s string, color bool) string
- type Case
- type Column
- type Count
- type DiffGroup
- type DocumentGroup
- type Encoder
- func (e Encoder) DiffGroups(groups []DiffGroup) error
- func (e Encoder) DocumentGroups(groups []DocumentGroup) error
- func (e Encoder) Documents(docs []map[string]any) error
- func (e Encoder) Errors(err error) error
- func (e Encoder) ImageGroups(groups []ImageGroup) error
- func (e Encoder) Images(images []string) error
- func (e Encoder) JSON(value any) error
- func (e Encoder) Lines(changes []LineChange) error
- func (e Encoder) Names(values iter.Seq[string]) error
- func (e Encoder) Native(report *dyff.Report) error
- func (e Encoder) Report(r *Report, results Encoder) error
- func (e Encoder) Tables(sections []Table) error
- func (e Encoder) YAML(value any) error
- type Format
- type ImageGroup
- type LineChange
- type Missing
- type Model
- type Names
- type Outcome
- type Primary
- type Report
- type ReportGroup
- type Subject
- type Table
- type TestReport
- type Warning
Constants ¶
const ( GlyphPass = "✓" GlyphFail = "✗" GlyphSkip = "‒" GlyphBlocked = "⊘" GlyphWarn = "⚠" )
Status glyphs shared across surfaces: a passing/success mark, a failure mark, and a skipped/secondary dash. Pair with Pass/Fail/Dim for color.
Variables ¶
This section is empty.
Functions ¶
func ColorEnabled ¶
ColorEnabled reports whether w should receive ANSI styling. colorprofile.Detect honors NO_COLOR / CLICOLOR(_FORCE) and TTY-ness; anything at or below Ascii (a pipe, a redirect, a dumb terminal) renders plain.
func Document ¶
Document assembles a footer from section blocks: a leading blank line parts it from preceding output, a single blank line separates each non-empty block, and it ends with a newline. Returns "" when every block is empty, so the caller writes nothing. Blocks carry no blank lines of their own — spacing lives here, in one place, so there's no per-section newline bookkeeping to drift. Shared by the build/diff failure report and the `flate test` roster.
func Elapsed ¶
Elapsed renders a duration compactly for live and summary timing: tenths of a second under a minute, m+ss above it.
func LineSubjects ¶
func LineSubjects(changes []LineChange, format Format) []manifest.NamedResource
LineSubjects inventories only the resource and producer labels this format prints.
func MessageTail ¶
MessageTail trims blank lines and paints each continuation line separately.
func NameLines ¶
func NameLines(changes []LineChange, names Names)
NameLines binds the invocation's resolved subjects to its line changes.
func Truncate ¶
Truncate shortens s to width visible columns, appending an ellipsis on overflow. It is ANSI- and wide-rune-aware (escape sequences and CJK width are counted correctly), so a styled line truncates by what's actually shown.
func Verdict ¶
Verdict renders a one-line run summary from an already painted glyph, counts joined by " · ", and a dim elapsed clock (omitted when zero). The first count always shows (even at zero, e.g. "0 passed"); later counts show only when non-zero. Returns "" when given no counts. Shared by the build/diff failure report and the `flate test` roster so both speak one verdict grammar.
Types ¶
type Case ¶
type Case struct {
ID manifest.NamedResource
Outcome Outcome
Reason string
}
Case is one resource result.
type Count ¶
Count is one labeled tally in a Verdict line: N items, a noun, and the paint that colors "<N> <Label>" (e.g. Fail for "failed").
type DocumentGroup ¶
type DocumentGroup struct {
Cluster string `json:"cluster"`
Documents []map[string]any `json:"documents"`
}
DocumentGroup holds one cluster's prepared documents.
type Encoder ¶
Encoder writes prepared values to one destination with resolved format and color.
func (Encoder) DiffGroups ¶
DiffGroups writes canonical per-cluster JSON changes and suppressions.
func (Encoder) DocumentGroups ¶
func (e Encoder) DocumentGroups(groups []DocumentGroup) error
DocumentGroups writes cluster framing around multiple document groups.
func (Encoder) ImageGroups ¶
func (e Encoder) ImageGroups(groups []ImageGroup) error
ImageGroups writes cluster framing around multiple image groups.
func (Encoder) Lines ¶
func (e Encoder) Lines(changes []LineChange) error
Lines consumes prepared resource differences once in unified or HTML format.
func (Encoder) Report ¶
Report writes results, warnings, cluster summaries and the test invocation total in order.
type Format ¶
type Format string
Format is the discriminator selected via -o on the CLI.
const ( FormatTable Format = "table" FormatYAML Format = "yaml" FormatJSON Format = "json" FormatName Format = "name" FormatHuman Format = "human" FormatGitHub Format = "github" FormatDiff Format = "diff" FormatHTML Format = "html" FormatBrief Format = "brief" FormatGitLab Format = "gitlab" FormatGitea Format = "gitea" )
Format values understood by the -o flag.
func DiffFormats ¶
func DiffFormats() []Format
DiffFormats lists accepted diff formats in help order, with the default first. Callers must not modify this list.
type ImageGroup ¶
type ImageGroup struct {
Cluster string `json:"cluster"`
Images []string `json:"images"`
Added bool `json:"added,omitempty"`
Removed bool `json:"removed,omitempty"`
Names []string `json:"-"`
}
ImageGroup holds one cluster's prepared images.
type LineChange ¶
type LineChange struct {
Resource, Parent Subject
ParentPath string
From, To string
Status, Label string
}
LineChange carries canonical diff values and resolved presentation labels.
func PrepareLines ¶
func PrepareLines(prepared diffprep.Prepared) ([]LineChange, error)
PrepareLines collects serialization errors before any report is written.
type Missing ¶
type Missing struct {
ID manifest.NamedResource
RequiredBy []manifest.NamedResource
}
Missing is a dependency that never rendered (absent from the store) yet was required by one or more resources — the other kind of root cause. RequiredBy lists the resources blocked on it (sorted).
type Model ¶
type Model struct {
// Subjects overrides group context; an empty non-nil map retains ordinary snapshot identities.
Subjects map[manifest.NamedResource]manifest.DiagnosticIdentity
Names *Names
Context string
Primary []Primary
Missing []Missing
// Blocked is the count of distinct derived (cascaded) failures. It is the
// verdict's "N blocked" figure — distinct resources, not the sum of the
// per-root Blocks/RequiredBy lists, which can overlap when one resource
// traces to more than one root (e.g. a failed parent AND a missing dep).
Blocked int
}
Model is the partitioned, deterministic view the renderer consumes.
type Names ¶
type Names struct {
Prefix string
Subjects map[manifest.NamedResource]Subject
}
Names contains the prepared labels for one retained cluster.
func PrepareNames ¶
func PrepareNames( clusters []string, inventory [][]manifest.NamedResource, subjects []map[manifest.NamedResource]manifest.DiagnosticIdentity, ) []Names
PrepareNames resolves cluster qualifiers and kind collisions across printed subjects.
type Primary ¶
type Primary struct {
ID manifest.NamedResource
Msg string
Blocks []manifest.NamedResource
}
Primary is a resource that failed on its own — a real render/template/build error. Blocks lists the resources whose failure cascaded from it (sorted).
type Report ¶
type Report struct {
Groups []ReportGroup
Warnings []Warning
Test bool
Elapsed time.Duration
Error error
}
Report coordinates the invocation's results, warnings and summaries.
type ReportGroup ¶
type ReportGroup struct {
Cluster string
Subjects map[manifest.NamedResource]manifest.DiagnosticIdentity
Models []Model
Test *TestReport
Names Names
}
ReportGroup contains one cluster's diagnostics and optional test roster.
type Subject ¶
type Subject struct {
ID manifest.NamedResource
Kind, Name string
}
Subject keeps canonical identity separate from its resolved human labels.
type TestReport ¶
type TestReport struct {
Cases []Case
Passed int
Skipped int
Failed int
// Blocked follows the roster in its supplied order, with prepared dependency reasons.
Blocked []Case
Matched int
}
TestReport is the aggregate outcome.
func (*TestReport) AnyFailed ¶
func (r *TestReport) AnyFailed() bool
AnyFailed includes blocked-only runs, even without a primary failure in scope.