Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RelaxedJSONPathExpression ¶
RelaxedJSONPathExpression attempts to be flexible with JSONPath expressions, it accepts:
- metadata.name (no leading '.' or curly braces '{...}'
- {metadata.name} (no leading '.')
- .metadata.name (no curly braces '{...}')
- {.metadata.name} (complete expression)
And transforms them all into a valid jsonpath expression:
{.metadata.name}
Types ¶
type RenderFunc ¶
type RenderFunc func() string
RenderFunc is the protype of human format renderer functions.
type Renderer ¶
type Renderer struct {
DefaultOutput string
Output string
// DefaultSort is the order a listing comes in when the caller asks
// for none, as a comma separated list of the fields to order on, each
// optionally prefixed with "-" to reverse it. Sort overrides it, and
// a Sort beginning with "+" extends it, the way Output and
// DefaultOutput already work. Without either, a listing is ordered
// on its columns, left to right.
DefaultSort string
Sort string
Color string
Data any
HumanRenderer RenderFunc
Colorize *palette.ColorPaletteFunc
Stream bool
}
Renderer hosts the renderer options and data, and exposes the rendering method.
func (Renderer) Print ¶
Print prints the representation of the data in one of the supported format (json, flat, human, ...).
The human format needs a RenderFunc to be passed. Print writes the rendered data to stdout, and returns what stopped it from rendering.
The error is returned rather than written to stderr, so that a command whose output could not be rendered fails instead of succeeding silently. A misspelled column or sort field used to print a line to stderr and exit 0, which a script reading the empty stdout had no way to notice.
type T ¶
type T int
T encodes as an integer one of the supported output formats (json, flat, human, table, csv)
const ( // Human is the preferred human friendly custom output format Human T = iota // JSON is the json output format JSON // Flat is the flattened json output format (a."b#b".c = d, a[0] = b) Flat // JSONLine is unindented json output format JSONLine // Tab is the customizable tabular output format Tab // Table is the simple tabular output format Table // CSV is the csv tabular output format CSV // YAML is the standard human readable, commentable, complex data representation YAML // Template is a custom user provided renderer Template )
func (T) MarshalText ¶
MarshalText marshals the enum as a quoted json string
func (*T) UnmarshalText ¶
UnmarshalText unmashals a quoted json string to the enum value