// SyncOrder recursively sorts the map node keys in 'to' node to match the order of // map node keys in 'from' node at same tree depth, additional keys are moved to the end // Field order might be altered due to round-tripping in arbitrary functions. // This functionality helps to retain the original order of fields to avoid unnecessary diffs. func SyncOrder(from, to *yaml.RNode) error { … } func syncOrder(from, to *yaml.RNode) error { … } // VisitElements calls fn for each element in a SequenceNode. // Returns an error for non-SequenceNodes func VisitElements(from, to *yaml.RNode, fn func(fNode, tNode *yaml.RNode) error) error { … } // VisitFields calls fn for each field in the RNode. // Returns an error for non-MappingNodes. func VisitFields(from, to *yaml.RNode, fn func(fNode, tNode *yaml.MapNode) error) error { … } // rearrangeHeadCommentOfSeqNode addresses a remote corner case due to moving a // map node in a sequence node with a head comment to the top func rearrangeHeadCommentOfSeqNode(node *yaml.Node) { … }