authorfuncs

package
v0.44.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

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

func Compile(functions map[string]*spec.Function) (*Library, error)

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

func (l *Library) Bind(ctx context.Context) template.FuncMap

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

func (l *Library) Fingerprint() string

Fingerprint returns a stable identifier for the function implementations so template caches distinguish same-named functions with different bodies.

func (*Library) Names

func (l *Library) Names() []string

Names returns the declared function names in stable order.

Jump to

Keyboard shortcuts

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