render

package
v1.12.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package render holds the CUE template helpers shared by the workload/trait render engine and by source resolution.

It exists because those two are separate packages that need the same four functions. Go's internal rules put a package under pkg/cue/definition out of reach of a sibling, so the shared parts live one level up rather than being duplicated - which is how they would drift.

Index

Constants

View Source
const ErrsFieldName = "errs"

ErrsFieldName is the field a template writes authored errors to.

View Source
const MaxAnnotationValueLen = 4096

MaxAnnotationValueLen is the budget for everything recorded on one object.

Kubernetes allows 256KB across all annotations on an object; these are diagnostic, so they take a small slice and leave the rest to whatever else annotates the entry. Contrast MaxPropertyValueLen, which caps one value within this budget.

View Source
const MaxPropertyValueLen = 512

MaxPropertyValueLen caps one property within that budget, so a single large value cannot crowd out every other property.

Variables

This section is empty.

Functions

func ContextLabels

func ContextLabels(ctx map[string]interface{}) map[string]string

ContextLabels renders the identity's context values as labels, so entries can be selected on them.

A value is emitted only when both halves are legal: the field name (with any index folded in) must be a valid label key, and the value a valid label value. Neither is guaranteed - an index like "example.org/service-name" would put a second slash in the key. Whatever is skipped is still recorded whole in AnnotationSourceContext, so only selectability is lost.

func Properties

func Properties(props map[string]interface{}) (string, bool, error)

Properties marshals a binding's properties for the annotation, replacing any value too large to record with a placeholder.

Clamping happens per value rather than on the finished JSON, because clipping a JSON document mid-string leaves something no reader can parse - and an annotation that has to be parsed to be useful is worth keeping valid. The placeholder keeps the shape intact and says what was dropped, so a reader still learns which properties distinguish this entry from its neighbours.

func Template

func Template(templ string) string

Template closes a definition's CUE over the fields a render supplies, so it compiles on its own.

`context` and `parameter` are open here rather than declared: the caller unifies real values in afterwards, and declaring shapes this package cannot know would reject templates it has no business judging.

func UserErrors

func UserErrors(val cue.Value, entityType, entityName string) []string

UserErrors reads the authored `errs:` field from a compiled CUE value and returns its non-empty entries.

A definition uses `errs:` to say why it refused, in its own words, rather than leaving a reader to infer it from a unification failure. A malformed field is logged and treated as empty, so a mistake in error reporting never masks the result it was reporting on.

Types

This section is empty.

Jump to

Keyboard shortcuts

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