summaryui

package
v0.33.5 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package summaryui holds the shared presentation primitives for the mirror pull and push summaries: the framed box, the accent colours, and the registry layout section. Keeping them here lets both summaries look identical.

Index

Constants

View Source
const (
	// FrameWidth is the inner width of the summary box, in runes.
	FrameWidth = 56
	// LabelWidth aligns the category labels in the summary body.
	LabelWidth = 11
	// NameWidth left-aligns module names and bundle artifact names.
	NameWidth = 30
	// SizeWidth right-aligns bundle artifact sizes.
	SizeWidth = 10
)

Variables

View Source
var (
	Frame   = color.New(color.FgHiBlack).SprintFunc()            // box borders - recede
	Title   = color.New(color.FgCyan, color.Bold).SprintFunc()   // block title
	Label   = color.New(color.FgCyan).SprintFunc()               // category labels (scan anchors)
	Count   = color.New(color.Bold).SprintFunc()                 // primary numbers
	Dim     = color.New(color.FgHiBlack).SprintFunc()            // units and secondary text
	Good    = color.New(color.FgGreen).SprintFunc()              // complete (e.g. 4/4 databases)
	Warn    = color.New(color.FgYellow).SprintFunc()             // attention (partial, not-available, non-default)
	Bad     = color.New(color.FgRed).SprintFunc()                // failure (cancelled)
	VEX     = color.New(color.FgMagenta).SprintFunc()            // VEX attestations (a distinct class)
	Version = color.New(color.FgGreen).SprintFunc()              // resolved versions (the headline)
	Size    = color.New(color.FgCyan).SprintFunc()               // bundle artifact sizes
	TotalSz = color.New(color.FgYellow, color.Bold).SprintFunc() // the bundle TOTAL - the action number
)

Semantic accent colours for the summary. fatih/color disables them when stdout is not a TTY or NO_COLOR is set (the summary is logged to stdout), so escape codes never reach pipes or files.

Apply every colour AFTER width padding (PadLabel, %-30s, %10s): the codes are zero-width on screen but count toward fmt's field widths and break columns.

Functions

func Bar

func Bar() string

Bar returns the coloured left border of a body line.

func ConfigureColor

func ConfigureColor()

ConfigureColor re-enables colour when FORCE_COLOR / CLICOLOR_FORCE is set (e.g. piping to `less -R` or capturing a coloured log). NO_COLOR wins; otherwise fatih/color's stdout-TTY check decides.

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration renders an elapsed duration compactly, keeping millisecond precision for sub-second runs (so a fast dry-run does not report "0s").

func HumanSize

func HumanSize(n int64) string

HumanSize returns a compact human-readable size using binary (IEC) units (e.g. "789 B", "12.3 KiB", "2.9 GiB"). The divisor is 1024, so the labels are KiB/MiB/GiB rather than the decimal KB/MB/GB - this keeps the printed unit honest with the math, which matters when an operator sizes transfer media off this number. Adapted from internal/cr/internal/output.HumanSize, which is not importable here because it lives behind the internal/cr/internal/ barrier.

func PadLabel

func PadLabel(name string) string

PadLabel formats a category label as a fixed-width "Name:" column.

func WriteModulesPathWarning

func WriteModulesPathWarning(b *strings.Builder, m mirror.ModulesPathReport, transferred bool)

WriteModulesPathWarning warns that modules were mirrored to a non-default registry path (--modules-path-suffix): the moved path in yellow plus a dimmed hint of the standard path.

It writes nothing unless the path was moved AND modules were actually transferred (transferred=true). A moved path is only worth flagging when modules went through it; a run that pulled or pushed no modules needs no warning.

The block is wrapped in blank lines to set it apart.

Root Segment names the registry base the modules path is rooted at, so the moved path reads as root + suffix against the default root + modules.

Example output for --modules-path-suffix mymods (colour stripped; the warning header and the Modules path are yellow):

║
║ Warning: modules use a non-default path (--modules-path-suffix)
║   Root Segment: registry.deckhouse.io/deckhouse/ee
║   Modules      registry.deckhouse.io/deckhouse/ee/mymods
║                default: registry.deckhouse.io/deckhouse/ee/modules
║

func WriteTopBorder

func WriteTopBorder(b *strings.Builder, title string)

WriteTopBorder writes the framed-block top border with the given title.

Types

This section is empty.

Jump to

Keyboard shortcuts

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