Documentation
¶
Index ¶
- Constants
- func ContextWithConfig(ctx context.Context, config *Config) context.Context
- func CreateBoolNode(value bool) *yaml.Node
- func CreateFloatNode(value float64) *yaml.Node
- func CreateIntNode(value int64) *yaml.Node
- func CreateMapNode(ctx context.Context, content []*yaml.Node) *yaml.Node
- func CreateOrUpdateKeyNode(ctx context.Context, key string, keyNode *yaml.Node) *yaml.Node
- func CreateOrUpdateMapNodeElement(ctx context.Context, key string, keyNode, valueNode, mapNode *yaml.Node) *yaml.Node
- func CreateOrUpdateScalarNode(ctx context.Context, value any, valueNode *yaml.Node) *yaml.Node
- func CreateOrUpdateSliceNode(ctx context.Context, elements []*yaml.Node, valueNode *yaml.Node) *yaml.Node
- func CreateStringNode(value string) *yaml.Node
- func DeleteMapNodeElement(ctx context.Context, key string, mapNode *yaml.Node) *yaml.Node
- func EqualNodes(a, b *yaml.Node) bool
- func GetMapElementNodes(ctx context.Context, mapNode *yaml.Node, key string) (*yaml.Node, *yaml.Node, bool)
- func IsMergeKey(node *yaml.Node) bool
- func NodeKindToString(kind yaml.Kind) string
- func NodeTagToString(tag string) string
- func ResolveAlias(node *yaml.Node) *yaml.Node
- func ResolveMergeKeys(content []*yaml.Node) []*yaml.Node
- func TypeToYamlTags(typ reflect.Type) []string
- func Walk(ctx context.Context, node *yaml.Node, visit VisitFunc) error
- type Config
- type IndentationStyle
- type OutputFormat
- type VisitFunc
Constants ¶
const ( // ErrTerminate is a sentinel error that can be returned from a Walk function to terminate the walk. ErrTerminate = errors.Error("terminate") )
Variables ¶
This section is empty.
Functions ¶
func ContextWithConfig ¶
func CreateBoolNode ¶ added in v1.3.0
func CreateFloatNode ¶ added in v1.3.0
func CreateIntNode ¶ added in v1.3.0
func CreateMapNode ¶ added in v0.2.1
func CreateOrUpdateKeyNode ¶
func CreateOrUpdateSliceNode ¶
func CreateStringNode ¶ added in v1.0.0
func DeleteMapNodeElement ¶
func EqualNodes ¶ added in v1.0.0
EqualNodes compares two yaml.Node instances for equality. It performs a deep comparison of the essential fields.
func GetMapElementNodes ¶
func IsMergeKey ¶ added in v1.19.2
IsMergeKey returns true if the given node is a YAML merge key (<<).
func NodeKindToString ¶ added in v0.2.2
NodeKindToString returns a human-readable string representation of a yaml.Kind. This helper function is useful for creating more user-friendly error messages when dealing with YAML node kinds in error reporting.
func NodeTagToString ¶ added in v1.7.5
func ResolveMergeKeys ¶ added in v1.19.2
ResolveMergeKeys processes a mapping node's content and expands any YAML merge keys (<<). Explicit keys in the mapping take precedence over merged keys (per the YAML merge key spec). Merged mappings are recursively flattened so nested merge chains are fully expanded. Returns new content with merge keys expanded, or the original content if no merge keys are present.
func TypeToYamlTags ¶ added in v1.7.5
TypeToYamlTags returns all acceptable YAML tags for a given reflect.Type. For numeric types, both the specific tag and !!str are acceptable since YAML can decode string representations of numbers. For pointer types, !!null is also acceptable.
Types ¶
type Config ¶
type Config struct {
KeyStringStyle yaml.Style // The default string style to use when creating new keys
ValueStringStyle yaml.Style // The default string style to use when creating new nodes
Indentation int // The indentation level of the document
IndentationStyle IndentationStyle // The indentation style of the document valid for JSON only
OutputFormat OutputFormat // The output format to use when marshalling
OriginalFormat OutputFormat // The original input format, helps detect when we are changing formats
TrailingNewline bool // Whether the original document had a trailing newline
}
func GetConfigFromContext ¶
func GetDefaultConfig ¶ added in v1.11.3
func GetDefaultConfig() *Config
type IndentationStyle ¶ added in v1.11.0
type IndentationStyle string
const ( IndentationStyleSpace IndentationStyle = "space" IndentationStyleTab IndentationStyle = "tab" )
func (IndentationStyle) ToIndent ¶ added in v1.11.0
func (i IndentationStyle) ToIndent() string
type OutputFormat ¶
type OutputFormat string
const ( OutputFormatJSON OutputFormat = "json" OutputFormatYAML OutputFormat = "yaml" )