template

package
v1.26.1 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package template renders keepup parameter/command strings.

It owns the Expander abstraction the engine depends on (dependency inversion): the engine asks "expand this string against these outputs and env" without knowing the implementation. The default implementation is Go's text/template with the sprig function library, plus two keepup-specific functions:

output "name"   → the captured stdout of a prior group
env    "KEY"    → a value from the merged keepup environment

A backward-compatibility shim rewrites the legacy "{{ output.X }}" form into the function form "{{ output \"X\" }}" before parsing, so configs written against the original substring expander keep working unchanged.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Refs

func Refs(s string) ([]string, error)

Refs returns the group names a template references via output("X") or out("X"), in encounter order (duplicates preserved; callers de-duplicate as needed). The following forms are all handled:

  • legacy dot form: {{ output.X }}
  • function form: {{ output "X" }} / {{ out "X" }}
  • dot-access form: {{ (out "X").ExitCode }} / {{ (out "X").Status }}

Only string-literal arguments are extractable; a dynamically-computed name (e.g. output (printf "g%d" 1)) cannot be resolved statically and is ignored.

Types

type Data

type Data struct {
	Outputs map[string]result.RunResult // group name → structured run result
	Env     map[string]string           // merged keepup environment
}

Data is the context a template is rendered against.

type Expander

type Expander interface {
	Expand(s string, data Data) (string, error)
}

Expander renders a templated string against Data. Implementations must be safe for concurrent use.

func NewExpander

func NewExpander() Expander

NewExpander returns the default Go-template + sprig Expander.

Jump to

Keyboard shortcuts

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