yamlsource

package
v1.234.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package yamlsource preserves explicit YAML function identity across the string-valued fields and serialization boundaries in the configuration pipeline. It has no dependency on configuration or evaluators.

Index

Constants

View Source
const BehaviorKey = "yaml_functions.explicit_tags"

BehaviorKey identifies the edition transition for automatic YAML function evaluation.

Variables

This section is empty.

Functions

func Comparable

func Comparable(value string) string

Comparable returns value with each source reduced to its tag and argument, so two values can be compared regardless of metadata such as checkout paths. The delimiters are process-local like the transport itself, so literal text can't spell a source. Compare results only within one process.

func Contains

func Contains(value string) bool

Contains reports whether text includes loader-preserved source, including expressions interpolated into a larger string without evaluation.

func ContainsTag

func ContainsTag(value, tag string) bool

ContainsTag reports whether text embeds source for a tag, as can happen when a template interpolates a computed value into a stack name.

func Display

func Display(value any) any

Display returns an ordinary representation for output formats without YAML tags. Internal JSON cloning should retain the transport strings instead.

func Embedded

func Embedded(value string) bool

Embedded reports whether value holds source that isn't the entire value: either text a template interpolated around it, or source a template function rewrote.

func Expression

func Expression(value string) string

Expression unwraps a transported value for an explicit evaluator. Source inside larger text is shown the same way, so internal metadata never reaches output.

func Replace

func Replace(value string, resolve func(token string, source Source) (string, error)) (string, error)

Replace substitutes each top-level source in value with the result of resolve, leaving surrounding text and malformed sources untouched. The callback receives the source's transport string and its decoded form.

func RestoreTags

func RestoreTags(node *yaml.Node)

RestoreTags restores explicit tags for public YAML output and YAML template passes. Plain strings, including quoted function expressions, are unchanged.

func Transformed

func Transformed(value string) bool

Transformed reports whether a template function rewrote source from this process, for example by changing its case. Its argument can no longer be recovered.

Types

type Source

type Source struct {
	Tag      string `json:"tag"`
	Argument string `json:"-"`
	File     string `json:"file,omitempty"`
	Line     int    `json:"line,omitempty"`
	Column   int    `json:"column,omitempty"`
}

Source identifies an explicit tag and its original scalar argument.

func Decode

func Decode(value string) (Source, bool)

Decode recognizes source created by this process, never a raw function string. The value must be exactly one source; see Embedded for sources inside larger text.

func (Source) Encode

func (s Source) Encode() string

Encode transports source through existing string fields. The argument stays readable so template rendering can operate on it without losing tag identity.

func (Source) Expression

func (s Source) Expression() string

Expression returns the spelling accepted by explicit evaluation APIs.

Jump to

Keyboard shortcuts

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