output

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatAndPrint

func FormatAndPrint(status *ph.HealthCheckResponse, cfg Config) error

FormatAndPrint handles common output formatting for health check responses.

func FormatNames

func FormatNames() []string

FormatNames returns a sorted list of registered format names. Used for flag usage text and validation error messages.

func RegisterFormatter

func RegisterFormatter(name string, f Formatter)

RegisterFormatter registers a formatter by name. Called from init() in each formatter file.

Types

type ColorConfig

type ColorConfig struct {
	Status   StatusColors `mapstructure:"status"`
	Name     string       `mapstructure:"name"`
	Type     string       `mapstructure:"type"`
	Message  string       `mapstructure:"message"`
	Duration string       `mapstructure:"duration"`
}

ColorConfig holds semantic color names for YAML output colorization. Color names follow mgutz/ansi format: "red", "green+b" (bold), "white+d" (dim), etc.

func DefaultColorConfig

func DefaultColorConfig() ColorConfig

DefaultColorConfig returns the default color configuration.

func (ColorConfig) Resolve

func (c ColorConfig) Resolve() ResolvedColors

Resolve converts semantic color names to ANSI escape codes.

type Config

type Config struct {
	Format     string // output format (json, junit, etc.)
	Flat       bool
	Quiet      int
	Compact    bool
	Colorize   bool           // colorize output (for supported formats)
	Colors     ResolvedColors // resolved ANSI color codes
	Components []string       // requested components for filtering flat output
}

Config holds configuration for formatting health check output.

func ConfigFromViper

func ConfigFromViper(v *viper.Viper) Config

ConfigFromViper creates a Config from viper settings. This is the standard way to build Config for commands that use the common output flags (flat, quiet, compact, component, output-format).

type Formatter

type Formatter interface {
	// Format converts the health check response to formatted output.
	// The cfg parameter provides output configuration (flat, quiet, compact).
	Format(status *ph.HealthCheckResponse, cfg Config) ([]byte, error)
}

Formatter defines the interface for output formatters. Implementations convert HealthCheckResponse to formatted output bytes.

func GetFormatter

func GetFormatter(name string) (Formatter, bool)

GetFormatter returns the formatter for the given name.

type JSONFormatter

type JSONFormatter struct{}

JSONFormatter formats health check responses as JSON.

func (*JSONFormatter) Format

func (f *JSONFormatter) Format(status *ph.HealthCheckResponse, cfg Config) ([]byte, error)

Format converts the health check response to JSON.

type JUnitFormatter

type JUnitFormatter struct{}

JUnitFormatter formats health check responses as JUnit XML.

func (*JUnitFormatter) Format

func (f *JUnitFormatter) Format(status *ph.HealthCheckResponse, cfg Config) ([]byte, error)

Format converts the health check response to JUnit XML.

type ResolvedColors

type ResolvedColors struct {
	Reset           string
	StatusHealthy   string
	StatusUnhealthy string
	StatusUnknown   string
	StatusLoop      string
	Name            string
	Type            string
	Message         string
	Duration        string
}

ResolvedColors holds pre-computed ANSI escape codes.

type StatusColors

type StatusColors struct {
	Healthy   string `mapstructure:"healthy"`
	Unhealthy string `mapstructure:"unhealthy"`
	Unknown   string `mapstructure:"unknown"`
	Loop      string `mapstructure:"loop"`
}

StatusColors holds color names for each status value.

type YAMLFormatter

type YAMLFormatter struct{}

YAMLFormatter formats health check responses as YAML.

func (*YAMLFormatter) Format

func (f *YAMLFormatter) Format(status *ph.HealthCheckResponse, cfg Config) ([]byte, error)

Format converts the health check response to YAML.

Jump to

Keyboard shortcuts

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