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
- func Comparable(value string) string
- func Contains(value string) bool
- func ContainsTag(value, tag string) bool
- func Display(value any) any
- func Embedded(value string) bool
- func Expression(value string) string
- func Replace(value string, resolve func(token string, source Source) (string, error)) (string, error)
- func RestoreTags(node *yaml.Node)
- func Transformed(value string) bool
- type Source
Constants ¶
const BehaviorKey = "yaml_functions.explicit_tags"
BehaviorKey identifies the edition transition for automatic YAML function evaluation.
Variables ¶
This section is empty.
Functions ¶
func Comparable ¶
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 ¶
Contains reports whether text includes loader-preserved source, including expressions interpolated into a larger string without evaluation.
func ContainsTag ¶
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 ¶
Display returns an ordinary representation for output formats without YAML tags. Internal JSON cloning should retain the transport strings instead.
func Embedded ¶
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 ¶
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 ¶
RestoreTags restores explicit tags for public YAML output and YAML template passes. Plain strings, including quoted function expressions, are unchanged.
func Transformed ¶
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 ¶
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 ¶
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 ¶
Expression returns the spelling accepted by explicit evaluation APIs.