var jsonRegexp … // 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} func RelaxedJSONPathExpression(pathExpression string) (string, error) { … } // NewCustomColumnsPrinterFromSpec creates a custom columns printer from a comma separated list of <header>:<jsonpath-field-spec> pairs. // e.g. NAME:metadata.name,API_VERSION:apiVersion creates a printer that prints: // // NAME API_VERSION // foo bar func NewCustomColumnsPrinterFromSpec(spec string, decoder runtime.Decoder, noHeaders bool) (*CustomColumnsPrinter, error) { … } func splitOnWhitespace(line string) []string { … } // NewCustomColumnsPrinterFromTemplate creates a custom columns printer from a template stream. The template is expected // to consist of two lines, whitespace separated. The first line is the header line, the second line is the jsonpath field spec // For example, the template below: // NAME API_VERSION // {metadata.name} {apiVersion} func NewCustomColumnsPrinterFromTemplate(templateReader io.Reader, decoder runtime.Decoder) (*CustomColumnsPrinter, error) { … } type Column … type CustomColumnsPrinter … func (s *CustomColumnsPrinter) PrintObj(obj runtime.Object, out io.Writer) error { … } func (s *CustomColumnsPrinter) printOneObject(obj runtime.Object, parsers []*jsonpath.JSONPath, out io.Writer) error { … }