template

package
v4.0.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const PlaceholderPrefix = "__argo__internal__placeholder-"

Variables

This section is empty.

Functions

func EnvMap

func EnvMap(replaceMap map[string]string) map[string]interface{}

func IsMissingVariableErr

func IsMissingVariableErr(err error) bool

func IsPlaceholder

func IsPlaceholder(s string) bool

IsPlaceholder reports whether s is an internal Argo placeholder value.

func NewPlaceholder

func NewPlaceholder(index int) string

NewPlaceholder generates an internal Argo placeholder string for the given index.

func Replace

func Replace(ctx context.Context, s string, replaceMap map[string]any, allowUnresolved bool) (string, error)

Replace takes a json-formatted string and performs variable replacement. Values are raw: a nil entry marks an absent optional (a skipped/omitted node's output with no default), and a simple tag resolving to nil is a terminal error regardless of allowUnresolved, which only governs tags whose key is missing entirely.

func ReplaceStrictAny added in v4.0.7

func ReplaceStrictAny(ctx context.Context, s string, replaceMap map[string]any, strictPrefixes []string) (string, error)

ReplaceStrictAny behaves like Replace but enforces that tags starting with any of strictPrefixes MUST be resolved, even if allowUnresolved behavior is otherwise active (implicit). It takes raw values, preserving nil entries so that expression tags can distinguish an absent (nil) value from an empty string (e.g. via `??`). A simple tag resolving to a nil value is a terminal error (not a missing-variable error): an absent optional must be handled by a producer default, a consumer input default (dropping the argument before substitution), or an expression fallback.

func ResolveVar

func ResolveVar(s string, m map[string]interface{}) (interface{}, error)

func ToAnyMap added in v4.0.7

func ToAnyMap(m map[string]string) map[string]any

ToAnyMap widens a string map for use with Replace. Callers that track absent optionals (skipped/omitted node outputs) build a map[string]any directly so nil entries survive.

func Validate

func Validate(s string, validator func(tag string) error) error

Types

type Template

type Template interface {
	Replace(ctx context.Context, replaceMap map[string]interface{}, allowUnresolved bool) (string, error)
	ReplaceStrict(ctx context.Context, replaceMap map[string]any, strictPrefixes []string) (string, error)
}

func NewTemplate

func NewTemplate(s string) (Template, error)

Jump to

Keyboard shortcuts

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