Documentation
¶
Overview ¶
Package output provides formatters for displaying Foundry resources in various formats (table, YAML, JSON).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateFormat ¶
ValidateFormat checks if a format string is valid.
Types ¶
type Formatter ¶
type Formatter interface {
// FormatVM formats a single VirtualMachine resource.
FormatVM(vm *v1alpha1.VirtualMachine) (string, error)
// FormatVMList formats a list of VirtualMachine resources.
FormatVMList(vms []*v1alpha1.VirtualMachine) (string, error)
}
Formatter formats Foundry resources for output.
func NewFormatter ¶
NewFormatter creates a new Formatter based on the specified format.
type JSONFormatter ¶
type JSONFormatter struct{}
JSONFormatter formats resources as JSON.
func (*JSONFormatter) FormatVM ¶
func (f *JSONFormatter) FormatVM(vm *v1alpha1.VirtualMachine) (string, error)
FormatVM formats a single VirtualMachine as JSON.
func (*JSONFormatter) FormatVMList ¶
func (f *JSONFormatter) FormatVMList(vms []*v1alpha1.VirtualMachine) (string, error)
FormatVMList formats a list of VirtualMachines as JSON. Outputs as a JSON array.
func (*JSONFormatter) FormatVMListAsItems ¶
func (f *JSONFormatter) FormatVMListAsItems(vms []*v1alpha1.VirtualMachine) (string, error)
FormatVMListAsItems formats a list of VirtualMachines as a JSON object with items array. This mimics Kubernetes List format:
{
"apiVersion": "foundry.cofront.xyz/v1alpha1",
"kind": "VirtualMachineList",
"items": [...]
}
type Options ¶
type Options struct {
// Format specifies the output format.
Format Format
// NoHeaders omits headers in table format.
NoHeaders bool
}
Options contains options for formatting output.
type TableFormatter ¶
type TableFormatter struct {
// NoHeaders omits the header row.
NoHeaders bool
}
TableFormatter formats resources as human-readable tables.
func (*TableFormatter) FormatVM ¶
func (f *TableFormatter) FormatVM(vm *v1alpha1.VirtualMachine) (string, error)
FormatVM formats a single VirtualMachine as a table row.
func (*TableFormatter) FormatVMList ¶
func (f *TableFormatter) FormatVMList(vms []*v1alpha1.VirtualMachine) (string, error)
FormatVMList formats a list of VirtualMachines as a table.
type YAMLFormatter ¶
type YAMLFormatter struct{}
YAMLFormatter formats resources as YAML.
func (*YAMLFormatter) FormatVM ¶
func (f *YAMLFormatter) FormatVM(vm *v1alpha1.VirtualMachine) (string, error)
FormatVM formats a single VirtualMachine as YAML.
func (*YAMLFormatter) FormatVMList ¶
func (f *YAMLFormatter) FormatVMList(vms []*v1alpha1.VirtualMachine) (string, error)
FormatVMList formats a list of VirtualMachines as YAML. Outputs as a YAML stream (multiple documents separated by ---).