Documentation
¶
Overview ¶
Package render interpolates the library's namespaced templates and evaluates expr conditions against a read-only view. It never exposes host objects with methods and never runs anything: a value that only exists at run time is reported as deferred.
Index ¶
- Variables
- func CompileCondition(source string, rv Vars) (func() (bool, error), error)
- func DetectCycle(level map[string]any) error
- func LookupEnv(env map[string]string, name string) (string, bool)
- func ReferencesAny(source string, names []string) bool
- func Refs(value string) []string
- func Render(source string, rv Vars) (string, error)
- func ResolveLevel(level map[string]any, base Vars) (map[string]any, error)
- type Error
- type Kind
- type Vars
Constants ¶
This section is empty.
Variables ¶
var ErrDeferred = errors.New("taskrun: value requires execution")
ErrDeferred marks a value that only exists at run time. Inspect reports it as deferred instead of executing anything.
Functions ¶
func CompileCondition ¶
CompileCondition compiles an expr condition against the read-only view. A condition may read vars, env, args, host and run metadata; it cannot call host methods. A condition that needs a declared dynamic variable resolves it through Vars.Dynamic, which Inspect leaves nil so the condition is reported as deferred instead of running a command.
func DetectCycle ¶
DetectCycle rejects static variable cycles. Only same-level references can form a cycle, so this check is decidable at load time, before any request runs.
func ReferencesAny ¶
ReferencesAny reports whether source mentions any of the identifiers as a standalone word. It decides whether a condition needs a dynamic variable, which Inspect must not evaluate.
Types ¶
type Kind ¶
type Kind int
Kind classifies a rendering failure so the caller can map it onto its own error kinds.
type Vars ¶
type Vars struct {
Vars map[string]any
Env map[string]string
Args []string
Host map[string]any
Run map[string]any
// Dynamic resolves a declared dynamic variable on demand. Inspect leaves it
// nil so that no command runs; a lookup then reports ErrDeferred.
Dynamic func(name string) (any, bool, error)
// DeferredNames lists the dynamic variable names declared for this level.
DeferredNames []string
}
Vars is the read-only view available to template interpolation and condition evaluation.