Documentation ¶
Overview ¶
Package template implements the JSONPath template format used by kubectl.
See https://kubernetes.io/docs/reference/kubectl/jsonpath/ for more information.
In some cases, it deviates slightly from the syntax accepted by kubectl's JSONPath expressions:
- The use of \ to escape the next character in identifiers is not supported.
- The use of @['x.y'] (equivalent to @.x.y) inside brackets is not supported, as it could conflict with an actual key in a JSON object.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultFormatter = template.StringFormatterFunc(func(ctx context.Context, v any) (string, error) { switch vt := v.(type) { case nil: return "", nil case []any: vs := make([]string, len(vt)) for i, vi := range vt { vs[i] = fmt.Sprintf("%v", vi) } return strings.Join(vs, " "), nil default: return fmt.Sprintf("%v", vt), nil } })
Functions ¶
func ExpressionLanguage ¶
func TemplateLanguage ¶
func TemplateLanguage(opts ...TemplateOption) gval.Language
Types ¶
type TemplateOption ¶
type TemplateOption func(tl *templateLanguage)
func WithExpressionLanguageVariableVisitor ¶
func WithExpressionLanguageVariableVisitor(visitor jsonpath.VariableVisitor) TemplateOption
func WithFormatter ¶
func WithFormatter(formatter template.StringFormatter) TemplateOption
Click to show internal directories.
Click to hide internal directories.