output

package
v0.36.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 35 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	BarColorSystem = "4" // blue
	BarColorCache  = "3" // yellow
	BarColorData   = "2" // green
	BarColorFree   = "8" // gray
)

ANSI colors used for the segments of a usage bar.

View Source
const (
	ChartColorCapacity = "1" // red
	ChartColorRequests = "3" // yellow
	ChartColorLatency  = "1" // red
)

Colors of the lines in a time chart.

Variables

This section is empty.

Functions

func BackupRestoreStatus added in v0.15.0

func BackupRestoreStatus(s backupv1.BackupRestoreStatus) string

BackupRestoreStatus returns a concise label for a BackupRestoreStatus.

func BackupScheduleStatus added in v0.15.0

func BackupScheduleStatus(s backupv1.BackupScheduleStatus) string

BackupScheduleStatus returns a concise label for a BackupScheduleStatus.

func BackupStatus added in v0.15.0

func BackupStatus(s backupv1.BackupStatus) string

BackupStatus returns a concise label for a BackupStatus.

func BarLegend added in v0.36.0

func BarLegend(label, barColor string, color bool) string

BarLegend renders a colored swatch followed by label, or just the label without color.

func BoolMark added in v0.16.0

func BoolMark(v bool) string

BoolMark formats a bool as "yes" or empty string ("").

func BoolYesNo added in v0.15.0

func BoolYesNo(v bool) string

BoolYesNo formats a bool as "yes" or "no".

func Bytes added in v0.31.0

func Bytes(v uint64) string

Bytes formats a measured byte size using IEC units (e.g. "0 B", "1.5 GiB"). Use resource.ByteQuantity for configured sizes, which must round-trip.

func ChartLegend added in v0.36.0

func ChartLegend(series []ChartSeries, color bool) string

ChartLegend renders the legend entries of a chart on a single line.

func ClusterAlertSeverity added in v0.32.0

func ClusterAlertSeverity(s monitoringv1.ClusterAlertSeverity) string

ClusterAlertSeverity returns a concise label for a ClusterAlertSeverity.

func ClusterAlertState added in v0.32.0

func ClusterAlertState(s monitoringv1.ClusterAlertState) string

ClusterAlertState returns a concise label for a ClusterAlertState.

func ClusterAlertType added in v0.32.0

func ClusterAlertType(t monitoringv1.ClusterAlertType) string

ClusterAlertType returns a concise label for a ClusterAlertType.

func ClusterCreationStatus added in v0.15.0

func ClusterCreationStatus(s hybridv1.QdrantClusterCreationStatus) string

ClusterCreationStatus returns a concise label for a QdrantClusterCreationStatus.

func ClusterNodeState added in v0.15.0

func ClusterNodeState(s clusterv1.ClusterNodeState) string

ClusterNodeState returns a concise label for a ClusterNodeState.

func ClusterPhase added in v0.15.0

func ClusterPhase(p clusterv1.ClusterPhase) string

ClusterPhase returns a concise label for a ClusterPhase.

func ColorEnabled added in v0.36.0

func ColorEnabled(w io.Writer) bool

ColorEnabled reports whether w is a terminal that supports colors, honoring NO_COLOR and TERM=dumb.

func CompactDuration added in v0.31.0

func CompactDuration(d time.Duration) string

CompactDuration formats d using Go duration notation without trailing zero units (e.g. "2m", "1h", "24h", "1h30m").

func Cores added in v0.34.0

func Cores(s string) string

Cores formats a CPU or GPU quantity from the API (e.g. "500m", "2") as a (fractional) number of cores (e.g. "0.5", "2"). Values that cannot be parsed are returned unchanged.

func CreatedAPIKey added in v0.31.0

func CreatedAPIKey(out io.Writer, key interface {
	GetId() string
	GetName() string
	GetKey() string
},
)

CreatedAPIKey prints the creation message and the one-time secret of an API key.

func DiffValue added in v0.10.0

func DiffValue(oldVal, newVal string) string

DiffValue formats a field value as "old => new" when the value changes, or just "val" when unchanged.

func Duration added in v0.30.0

func Duration(d time.Duration) string

Duration formats d as a human-readable duration with days as the largest unit and at most two units (e.g. "1 day", "30 days", "1 day 12 hours").

func FormatMillicents added in v0.16.0

func FormatMillicents(mc int32, currency string) string

FormatMillicents formats millicent pricing as a human-readable price string. 1 unit of currency = 100,000 millicents. Returns "free" for zero. currency should be an ISO 4217 code (e.g. "USD").

func FullDateTime

func FullDateTime(t time.Time) string

FullDateTime formats t as "2006-01-02 15:04:05 UTC". Returns empty string for zero time.

func HumanTime

func HumanTime(t time.Time) string

HumanTime returns a relative human-readable time (e.g., "3 hours ago"). Returns empty string for zero time.

func HybridComponentPhase added in v0.15.0

HybridComponentPhase returns a concise label for a HybridCloudEnvironmentComponentStatusPhase.

func HybridEnvironmentPhase added in v0.15.0

func HybridEnvironmentPhase(p hybridv1.HybridCloudEnvironmentStatusPhase) string

HybridEnvironmentPhase returns a concise label for a HybridCloudEnvironmentStatusPhase.

func JoinOrDefault added in v0.30.0

func JoinOrDefault(items []string, fallback string) string

JoinOrDefault joins items with ", ", or returns fallback when items is empty.

func KeySecret added in v0.31.0

func KeySecret(out io.Writer, secret string)

KeySecret prints the one-time secret of a newly created key, if present.

func MillicoresAsCores added in v0.34.0

func MillicoresAsCores(v float64) string

MillicoresAsCores formats a measured millicore value as a (fractional) number of cores (e.g. 1500 → "1.5").

func Milliseconds added in v0.31.0

func Milliseconds(v float64) string

Milliseconds formats a value in milliseconds with one decimal (e.g. "12.3ms").

func ModelModality added in v0.29.0

func ModelModality(m bookingv1.ModelModality) string

ModelModality returns a concise label for a ModelModality.

func OptionalValue added in v0.10.0

func OptionalValue(v any, fallback string) string

OptionalValue formats an optional pointer value as a string. Returns fallback for nil pointers. Supports any pointer type. Booleans are formatted as "yes"/"no"; all other types use their default format.

func PackageCPU added in v0.35.0

func PackageCPU(rc *bookingv1.ResourceConfiguration) string

PackageCPU returns a package's CPU as a (fractional) number of cores (e.g. "0.5", "4"). A value that cannot be parsed is returned as is.

func PackageDisk added in v0.35.0

func PackageDisk(rc *bookingv1.ResourceConfiguration) string

PackageDisk returns a package's included disk in canonical form (e.g. "64GiB"). A value that cannot be parsed is returned as is.

func PackageGPU added in v0.35.0

func PackageGPU(rc *bookingv1.ResourceConfiguration) string

PackageGPU returns a package's GPU as a (fractional) number of GPUs (e.g. "1"), or "n/a" for a package without a GPU. A value that cannot be parsed is returned as is.

func PackageRAM added in v0.35.0

func PackageRAM(rc *bookingv1.ResourceConfiguration) string

PackageRAM returns a package's RAM in canonical form (e.g. "16GiB"). A value that cannot be parsed is returned as is.

func PackageTier added in v0.15.0

func PackageTier(t bookingv1.PackageTier) string

PackageTier returns a concise label for a PackageTier.

func Percent added in v0.36.0

func Percent(v float64) string

Percent formats a percentage with at most one decimal (e.g. "42.5%", "100%").

func PercentOf added in v0.36.0

func PercentOf(v, total float64) float64

PercentOf returns v as a percentage of total, rounded to one decimal, or 0 when total is 0.

func PrintJSON

func PrintJSON(w io.Writer, v any) error

PrintJSON marshals items as JSON and writes to w. For proto messages, uses protojson for proper field naming.

func Rate added in v0.31.0

func Rate(v float64) string

Rate formats a per-second rate with two decimals (e.g. "1.25/s").

func RetentionPeriod added in v0.31.0

func RetentionPeriod(d *durationpb.Duration) string

RetentionPeriod formats a backup retention period; an unset period means the backups are kept indefinitely.

func RoleType added in v0.20.0

func RoleType(v iamv1.RoleType) string

RoleType formats a RoleType enum for display.

func Significant added in v0.36.0

func Significant(v float64, digits int) string

Significant formats v rounded to the given number of significant digits, without trailing zeros or an exponent (e.g. 0.0016, 1.25, 1300).

func SpaceAlertSeverity added in v0.31.0

func SpaceAlertSeverity(s serverlessmonitoringv1.SpaceAlertSeverity) string

SpaceAlertSeverity returns a concise label for a serverless SpaceAlertSeverity.

func SpaceAlertState added in v0.31.0

SpaceAlertState returns a concise label for a serverless SpaceAlertState.

func SpaceAlertType added in v0.31.0

SpaceAlertType returns a concise label for a serverless SpaceAlertType.

func SpaceApiKeyPhase added in v0.30.0

func SpaceApiKeyPhase(p spaceauthv1.SpaceApiKeyStatePhase) string

SpaceApiKeyPhase returns a concise label for a serverless SpaceApiKeyStatePhase.

func SpaceBackupRestoreStatus added in v0.30.0

func SpaceBackupRestoreStatus(s spacebackupv1.BackupRestoreStatus) string

SpaceBackupRestoreStatus returns a concise label for a serverless BackupRestoreStatus.

func SpaceBackupScheduleStatus added in v0.30.0

func SpaceBackupScheduleStatus(s spacebackupv1.BackupScheduleStatus) string

SpaceBackupScheduleStatus returns a concise label for a serverless BackupScheduleStatus.

func SpaceBackupStatus added in v0.30.0

func SpaceBackupStatus(s spacebackupv1.BackupStatus) string

SpaceBackupStatus returns a concise label for a serverless BackupStatus.

func SpaceCollectionAccessType added in v0.30.0

func SpaceCollectionAccessType(t spaceauthv1.CollectionAccessRuleAccessType) string

SpaceCollectionAccessType returns a concise label for a serverless CollectionAccessRuleAccessType.

func SpaceGlobalAccessType added in v0.30.0

func SpaceGlobalAccessType(t spaceauthv1.GlobalAccessRuleAccessType) string

SpaceGlobalAccessType returns a concise label for a serverless GlobalAccessRuleAccessType.

func SpacePhase added in v0.30.0

func SpacePhase(p spacev1.SpaceStatePhase) string

SpacePhase returns a concise label for a serverless SpaceStatePhase.

func TerminalWidth added in v0.36.0

func TerminalWidth(w io.Writer, fallback int) int

TerminalWidth returns the width of the terminal w writes to, or fallback when w is not a terminal.

func TimeChart added in v0.36.0

func TimeChart(series []ChartSeries, opts TimeChartOptions) string

TimeChart renders series over the time range in opts. Line series are drawn as braille lines in order, so a later one is drawn over an earlier one where they meet, and filled series as stacked areas on top of them. Points outside the time range and series without points are left out.

func TimeChartYLabelWidth added in v0.36.0

func TimeChartYLabelWidth(series []ChartSeries, opts TimeChartOptions) int

TimeChartYLabelWidth returns the width of the widest label on the Y axis of the chart TimeChart draws for series and opts.

func TolerationEffect added in v0.15.0

func TolerationEffect(eff clusterv1.TolerationEffect) string

TolerationEffect returns a concise label for a TolerationEffect.

func TolerationOperator added in v0.15.0

func TolerationOperator(op clusterv1.TolerationOperator) string

TolerationOperator returns a concise label for a TolerationOperator.

func UnlimitedIfZero added in v0.31.0

func UnlimitedIfZero(formatted string, v uint64) string

UnlimitedIfZero returns "unlimited" when v is 0 and formatted otherwise. It is used for limits where 0 means no limit.

func UsageBar added in v0.36.0

func UsageBar(segments []BarSegment, total float64, width int, color bool) string

UsageBar renders segments as a horizontal stacked bar of width cells, scaled so that a full bar equals total. With color, every segment has its own color and the remaining capacity is drawn as a gray track. Without color, the used part is drawn inside brackets, since uncolored segments look the same.

func UserStatus added in v0.20.0

func UserStatus(x iamv1.UserStatus) string

UserStatus formats an iamv1.UserStatus enum for display.

func VectorType added in v0.29.0

func VectorType(t bookingv1.VectorType) string

VectorType returns a concise label for a VectorType.

Types

type BarSegment added in v0.36.0

type BarSegment struct {
	Value float64
	Color string
}

BarSegment is one stacked part of a usage bar.

type ChartSeries added in v0.36.0

type ChartSeries struct {
	Name   string
	Color  string
	Points []TimePoint
	// Fill draws the area below the line instead of the line. Filled series
	// are stacked: each one must include the values of the filled series
	// before it, so it is drawn on top of them. Without color, a filled series
	// is drawn as a line, since areas of the same look would hide each other.
	Fill bool
}

ChartSeries is one line of a time chart.

type Table

type Table[T any] struct {
	// contains filtered or unexported fields
}

Table renders items as an ASCII table.

func NewTable

func NewTable[T any](w io.Writer) *Table[T]

NewTable creates a new Table that writes to the given writer.

func (*Table[T]) AddField

func (t *Table[T]) AddField(name string, fn func(T) string)

AddField adds a column to the table with a header name and a field extraction function.

func (*Table[T]) AddWrappedField added in v0.32.0

func (t *Table[T]) AddWrappedField(name string, maxWidth int, fn func(T) string)

AddWrappedField adds a column whose values are word-wrapped onto multiple lines when they are longer than maxWidth characters. Use it for free-text values such as descriptions that would otherwise make the table too wide.

func (*Table[T]) Render added in v0.20.0

func (t *Table[T]) Render()

Render writes the table using previously stored items (via SetItems). Headers are suppressed when SetNoHeaders(true) has been called.

func (*Table[T]) SetItems added in v0.20.0

func (t *Table[T]) SetItems(items []T)

SetItems stores items for deferred rendering via Render.

func (*Table[T]) SetNoHeaders added in v0.20.0

func (t *Table[T]) SetNoHeaders(v bool)

SetNoHeaders controls whether the header row is suppressed when rendering.

func (*Table[T]) Write

func (t *Table[T]) Write(items []T)

Write renders the table with the given items immediately.

type TableRenderer added in v0.20.0

type TableRenderer interface {
	SetNoHeaders(bool)
	Render()
}

TableRenderer can render table output with configurable header suppression. Table[T] implements this interface after SetItems is called.

type TimeChartOptions added in v0.36.0

type TimeChartOptions struct {
	Since, Until time.Time
	// YMax is the highest value the Y axis must show. It is raised to fit
	// every value, then rounded up to a value that gives even labels, with
	// some room above it.
	YMax float64
	// YTop is the least top of the Y axis, such as 100 for a percentage.
	// Unlike YMax, it gets no room above it.
	YTop float64
	// YUnit is the unit labels are rounded to, such as 1 GiB for bytes.
	// It defaults to 1.
	YUnit  float64
	Width  int
	Height int
	// YLabel formats the values on the Y axis.
	YLabel func(float64) string
	// YLabelWidth pads the labels on the Y axis to at least this width, so
	// charts printed below each other line up. See TimeChartYLabelWidth.
	YLabelWidth int
	Color       bool
}

TimeChartOptions configures TimeChart.

type TimePoint added in v0.36.0

type TimePoint struct {
	Time  time.Time
	Value float64
}

TimePoint is a value at a point in time.

Jump to

Keyboard shortcuts

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