Documentation
¶
Overview ¶
Package authorfuncs compiles solution-author-defined Go template helper functions (spec.functions) into a bindable library of template.FuncMap entries.
Each declared function has ordered, typed parameters and exactly one body:
- a CEL expression (spec-idiomatic; returns any typed value), evaluated with the bound arguments under the args namespace (_.args.name), or
- a Go template body (Helm-style named template; returns a string), rendered with the bound arguments as {{ .args.name }} and able to call sibling author functions and all built-in helpers.
Compilation validates names, parameters, bodies, and -- for template bodies -- the acyclicity of the author-function call graph, which guarantees rendering terminates. The compiled Library implements provider.TemplateFuncBinder so it can be injected into go-template provider execution via the provider context without the provider or executor packages importing this package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Library ¶
type Library struct {
// contains filtered or unexported fields
}
Library is a compiled, immutable set of author functions. Its zero value is not usable; construct one with Compile. A nil *Library is valid and behaves as an empty library (Bind returns nil, Fingerprint returns "").
func Compile ¶
Compile validates the given function definitions and returns a Library. It returns (nil, nil) when functions is empty. All validation problems are aggregated into a single error so authors see every issue at once.
func (*Library) Bind ¶
Bind returns the author functions as a template.FuncMap whose closures capture ctx for CEL evaluation and nested template rendering. It returns nil for a nil or empty library.
func (*Library) Fingerprint ¶
Fingerprint returns a stable identifier for the function implementations so template caches distinguish same-named functions with different bodies.