Documentation
¶
Index ¶
- Constants
- func BackupRestoreStatus(s backupv1.BackupRestoreStatus) string
- func BackupScheduleStatus(s backupv1.BackupScheduleStatus) string
- func BackupStatus(s backupv1.BackupStatus) string
- func BarLegend(label, barColor string, color bool) string
- func BoolMark(v bool) string
- func BoolYesNo(v bool) string
- func Bytes(v uint64) string
- func ChartLegend(series []ChartSeries, color bool) string
- func ClusterAlertSeverity(s monitoringv1.ClusterAlertSeverity) string
- func ClusterAlertState(s monitoringv1.ClusterAlertState) string
- func ClusterAlertType(t monitoringv1.ClusterAlertType) string
- func ClusterCreationStatus(s hybridv1.QdrantClusterCreationStatus) string
- func ClusterNodeState(s clusterv1.ClusterNodeState) string
- func ClusterPhase(p clusterv1.ClusterPhase) string
- func ColorEnabled(w io.Writer) bool
- func CompactDuration(d time.Duration) string
- func Cores(s string) string
- func CreatedAPIKey(out io.Writer, key interface{ ... })
- func DiffValue(oldVal, newVal string) string
- func Duration(d time.Duration) string
- func FormatMillicents(mc int32, currency string) string
- func FullDateTime(t time.Time) string
- func HumanTime(t time.Time) string
- func HybridComponentPhase(p hybridv1.HybridCloudEnvironmentComponentStatusPhase) string
- func HybridEnvironmentPhase(p hybridv1.HybridCloudEnvironmentStatusPhase) string
- func JoinOrDefault(items []string, fallback string) string
- func KeySecret(out io.Writer, secret string)
- func MillicoresAsCores(v float64) string
- func Milliseconds(v float64) string
- func ModelModality(m bookingv1.ModelModality) string
- func OptionalValue(v any, fallback string) string
- func PackageCPU(rc *bookingv1.ResourceConfiguration) string
- func PackageDisk(rc *bookingv1.ResourceConfiguration) string
- func PackageGPU(rc *bookingv1.ResourceConfiguration) string
- func PackageRAM(rc *bookingv1.ResourceConfiguration) string
- func PackageTier(t bookingv1.PackageTier) string
- func Percent(v float64) string
- func PercentOf(v, total float64) float64
- func PrintJSON(w io.Writer, v any) error
- func Rate(v float64) string
- func RetentionPeriod(d *durationpb.Duration) string
- func RoleType(v iamv1.RoleType) string
- func Significant(v float64, digits int) string
- func SpaceAlertSeverity(s serverlessmonitoringv1.SpaceAlertSeverity) string
- func SpaceAlertState(s serverlessmonitoringv1.SpaceAlertState) string
- func SpaceAlertType(t serverlessmonitoringv1.SpaceAlertType) string
- func SpaceApiKeyPhase(p spaceauthv1.SpaceApiKeyStatePhase) string
- func SpaceBackupRestoreStatus(s spacebackupv1.BackupRestoreStatus) string
- func SpaceBackupScheduleStatus(s spacebackupv1.BackupScheduleStatus) string
- func SpaceBackupStatus(s spacebackupv1.BackupStatus) string
- func SpaceCollectionAccessType(t spaceauthv1.CollectionAccessRuleAccessType) string
- func SpaceGlobalAccessType(t spaceauthv1.GlobalAccessRuleAccessType) string
- func SpacePhase(p spacev1.SpaceStatePhase) string
- func TerminalWidth(w io.Writer, fallback int) int
- func TimeChart(series []ChartSeries, opts TimeChartOptions) string
- func TimeChartYLabelWidth(series []ChartSeries, opts TimeChartOptions) int
- func TolerationEffect(eff clusterv1.TolerationEffect) string
- func TolerationOperator(op clusterv1.TolerationOperator) string
- func UnlimitedIfZero(formatted string, v uint64) string
- func UsageBar(segments []BarSegment, total float64, width int, color bool) string
- func UserStatus(x iamv1.UserStatus) string
- func VectorType(t bookingv1.VectorType) string
- type BarSegment
- type ChartSeries
- type Table
- type TableRenderer
- type TimeChartOptions
- type TimePoint
Constants ¶
const ( BarColorSystem = "4" // blue BarColorCache = "3" // yellow BarColorData = "2" // green BarColorFree = "8" // gray )
ANSI colors used for the segments of a usage bar.
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
BarLegend renders a colored swatch followed by label, or just the label without color.
func Bytes ¶ added in v0.31.0
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
ColorEnabled reports whether w is a terminal that supports colors, honoring NO_COLOR and TERM=dumb.
func CompactDuration ¶ added in v0.31.0
CompactDuration formats d using Go duration notation without trailing zero units (e.g. "2m", "1h", "24h", "1h30m").
func Cores ¶ added in v0.34.0
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
DiffValue formats a field value as "old => new" when the value changes, or just "val" when unchanged.
func Duration ¶ added in v0.30.0
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
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 ¶
FullDateTime formats t as "2006-01-02 15:04:05 UTC". Returns empty string for zero time.
func HumanTime ¶
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
func HybridComponentPhase(p hybridv1.HybridCloudEnvironmentComponentStatusPhase) string
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
JoinOrDefault joins items with ", ", or returns fallback when items is empty.
func KeySecret ¶ added in v0.31.0
KeySecret prints the one-time secret of a newly created key, if present.
func MillicoresAsCores ¶ added in v0.34.0
MillicoresAsCores formats a measured millicore value as a (fractional) number of cores (e.g. 1500 → "1.5").
func Milliseconds ¶ added in v0.31.0
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
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
Percent formats a percentage with at most one decimal (e.g. "42.5%", "100%").
func PercentOf ¶ added in v0.36.0
PercentOf returns v as a percentage of total, rounded to one decimal, or 0 when total is 0.
func PrintJSON ¶
PrintJSON marshals items as JSON and writes to w. For proto messages, uses protojson for proper field naming.
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 Significant ¶ added in v0.36.0
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
func SpaceAlertState(s serverlessmonitoringv1.SpaceAlertState) string
SpaceAlertState returns a concise label for a serverless SpaceAlertState.
func SpaceAlertType ¶ added in v0.31.0
func SpaceAlertType(t serverlessmonitoringv1.SpaceAlertType) string
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
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
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
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 (*Table[T]) AddField ¶
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
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
SetNoHeaders controls whether the header row is suppressed when rendering.
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.