template

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2022 License: Apache-2.0 Imports: 8 Imported by: 1

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 ExpressionLanguage() gval.Language

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL