Documentation ¶
Index ¶
- func JSONToYAML(jsonIn []byte) ([]byte, error)
- func Render(writer io.Writer, outputFormat string, commandOutputs ...Output) (err error)
- type Combined
- type CombinedSection
- type DetailRow
- type DetailSection
- type Details
- type Error
- type MarshaledWithHumanDetails
- type MarshaledWithHumanOutput
- type None
- type OnlyMarshaled
- type Output
- type Raw
- type Table
- type TableColumn
- type TableRow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JSONToYAML ¶
JSONToYAML converts JSON bytes into YAML bytes. This allows using key names from JSON field tags also for YAML output. This has some side-effects (e.g., timestamps will be double-quoted in output) but this is lesser evil than adding yaml field tags everywhere in our Go types.
Types ¶
type Combined ¶
type Combined []CombinedSection
Combined represents multiple outputs combined and displayed sequentially (or wrapped into the same object)
func (Combined) MarshalHuman ¶
MarshalHuman returns output in a human-readable form
func (Combined) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (Combined) MarshalRawMap ¶
MarshalRawMap implements output.Output
type CombinedSection ¶
CombinedSection represents a single section of a combined output
type DetailRow ¶
type DetailRow struct { Title string // used for human-readable representations Key string // user for machine-readable (json, yaml) representations Value interface{} Colour text.Colors Format func(val interface{}) (text.Colors, string, error) }
DetailRow represents a single row in the details view, with a title and a value
type DetailSection ¶
type DetailSection struct { Title string // used for human-readable representations Key string // user for machine-readable (json, yaml) representations Rows []DetailRow }
DetailSection represents a section in the details view
func (DetailSection) MarshalJSON ¶
func (d DetailSection) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler
type Details ¶
type Details struct {
Sections []DetailSection
}
Details implements output.Output for a details-style view
func (Details) MarshalHuman ¶
MarshalHuman marshals details and returns a human readable []byte
func (Details) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (Details) MarshalRawMap ¶
MarshalRawMap implements output.Output
type Error ¶
Error implements output.Command for a return value that is an error
func (Error) MarshalHuman ¶
MarshalHuman implements output.Output
func (Error) MarshalJSON ¶
MarshalJSON implements json.Marshaler and output.Output
func (Error) MarshalRawMap ¶
MarshalRawMap implements output.Output
type MarshaledWithHumanDetails ¶
type MarshaledWithHumanDetails struct { Value interface{} Details []DetailRow }
MarshaledWithHumanDetails implements output.Command for a return value that is displayed as raw marshaled in JSON and YAML or as human details, such as UUID or IP address, eg. most create commands.
func (MarshaledWithHumanDetails) MarshalHuman ¶
func (d MarshaledWithHumanDetails) MarshalHuman() ([]byte, error)
MarshalHuman implements output.Output For MarshaledWithHumanDetails outputs, we return *only* the details part in humanized output
func (MarshaledWithHumanDetails) MarshalJSON ¶
func (d MarshaledWithHumanDetails) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler and output.Output
func (MarshaledWithHumanDetails) MarshalRawMap ¶
func (d MarshaledWithHumanDetails) MarshalRawMap() (map[string]interface{}, error)
MarshalRawMap implements output.Output
type MarshaledWithHumanOutput ¶
type MarshaledWithHumanOutput struct { Value interface{} Output Output }
MarshaledWithHumanOutput implements output.Command for a return value that passes through raw marshaled JSON or YAML and only affects human output. Like MarshaledWithHumanDetails, but allows more complex output.
func (MarshaledWithHumanOutput) MarshalHuman ¶
func (d MarshaledWithHumanOutput) MarshalHuman() ([]byte, error)
MarshalHuman implements output.Output For MarshaledWithHumanDetails outputs, we return *only* the details part in humanized output
func (MarshaledWithHumanOutput) MarshalJSON ¶
func (d MarshaledWithHumanOutput) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler and output.Output
func (MarshaledWithHumanOutput) MarshalRawMap ¶
func (d MarshaledWithHumanOutput) MarshalRawMap() (map[string]interface{}, error)
MarshalRawMap implements output.Output
type None ¶
type None struct{}
None is used when the command returns no output
func (None) MarshalHuman ¶
MarshalHuman implements output.Output
func (None) MarshalJSON ¶
MarshalJSON implements output.Output
func (None) MarshalRawMap ¶
MarshalRawMap implements output.Output
type OnlyMarshaled ¶
type OnlyMarshaled struct {
Value interface{}
}
OnlyMarshaled implements output.Command for a return value that is only displayed as raw marshaled in JSON and YAML eg. most 'state change' commands
func (OnlyMarshaled) MarshalHuman ¶
func (d OnlyMarshaled) MarshalHuman() ([]byte, error)
MarshalHuman implements output.Output For OnlyMarshaled outputs, we dont return anything in humanized output as it's assumed the log output is what the user wants and it is down to the command itself to provide that.
func (OnlyMarshaled) MarshalJSON ¶
func (d OnlyMarshaled) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler and output.Output
func (OnlyMarshaled) MarshalRawMap ¶
func (d OnlyMarshaled) MarshalRawMap() (map[string]interface{}, error)
MarshalRawMap implements output.Output
type Output ¶
type Output interface { json.Marshaler MarshalHuman() ([]byte, error) MarshalRawMap() (map[string]interface{}, error) }
Output represent output from a command that can be rendered as JSON, YAML or human-readable
type Raw ¶
type Raw []byte
Raw is a way to output raw data to the user. It is *only* supported in humanized output and used for generating shell completion scripts.
func (Raw) MarshalHuman ¶
MarshalHuman implements output.Output
func (Raw) MarshalJSON ¶
MarshalJSON implements output.Output
func (Raw) MarshalRawMap ¶
MarshalRawMap implements output.Output
type Table ¶
type Table struct { Columns []TableColumn Rows []TableRow EmptyMessage string HideHeader bool }
Table represents command output rendered as a table
func (Table) MarshalHuman ¶
MarshalHuman returns table output in a human-readable form
func (Table) MarshalJSON ¶
MarshalJSON implements json.Marshaler
func (Table) MarshalRawMap ¶
MarshalRawMap implements output.Output