mirror of
https://github.com/mikefarah/yq.git
synced 2026-03-10 15:54:26 +00:00
goccy decoder supports merge maps
This commit is contained in:
parent
f89605e3c0
commit
72fa3cca98
@ -167,8 +167,13 @@ func (o *CandidateNode) UnmarshalGoccyYAML(node ast.Node, cm yaml.CommentMap, an
|
||||
o.Value = aliasNode.Value.String()
|
||||
o.Alias = anchorMap[o.Value]
|
||||
|
||||
case ast.MergeKeyType:
|
||||
log.Debugf("UnmarshalYAML - a merge key")
|
||||
o.Kind = ScalarNode
|
||||
o.Value = "<<"
|
||||
|
||||
default:
|
||||
log.Debugf("UnmarshalYAML - node idea of the type!!")
|
||||
log.Debugf("UnmarshalYAML - no idea of the type!!\n%v: %v", node.Type(), node.String())
|
||||
}
|
||||
log.Debugf("KIND: %v", o.Kind)
|
||||
return nil
|
||||
|
||||
@ -78,9 +78,6 @@ func (o *CandidateNode) copyToYamlNode(node *yaml.Node) {
|
||||
node.Value = o.Value
|
||||
node.Anchor = o.Anchor
|
||||
|
||||
// node.Alias = TODO - find Alias in our own structure
|
||||
// might need to be a post process thing
|
||||
|
||||
node.HeadComment = o.HeadComment
|
||||
|
||||
node.LineComment = o.LineComment
|
||||
|
||||
@ -219,12 +219,24 @@ var goccyYamlFormatScenarios = []formatScenario{
|
||||
// expression: "explode(.)",
|
||||
// expected: "a: mike\nb: mike\n",
|
||||
// },
|
||||
// {
|
||||
// description: "multi document anchor map",
|
||||
// skipDoc: true,
|
||||
// input: "a: &remember mike\n---\nb: *remember",
|
||||
// expression: "explode(.)",
|
||||
// expected: "a: mike\n---\nb: mike\n",
|
||||
// },
|
||||
// {
|
||||
// description: "merge anchor",
|
||||
// skipDoc: true,
|
||||
// input: "a: &remember\n c: mike\nb:\n <<: *remember",
|
||||
// expected: "a: &remember\n c: mike\nb:\n <<: *remember\n",
|
||||
// },
|
||||
{
|
||||
description: "multi document anchor map",
|
||||
description: "custom tag",
|
||||
skipDoc: true,
|
||||
input: "a: &remember mike\n---\nb: *remember",
|
||||
expression: "explode(.)",
|
||||
expected: "a: mike\n---\nb: mike\n",
|
||||
input: "a: !cat mike",
|
||||
expected: "a: !cat mike\n",
|
||||
},
|
||||
// {
|
||||
// description: "basic - [~]",
|
||||
@ -256,6 +268,7 @@ var goccyYamlFormatScenarios = []formatScenario{
|
||||
// input: "[1, 2]",
|
||||
// expected: "[1, 2]\n",
|
||||
// },
|
||||
|
||||
}
|
||||
|
||||
func testGoccyYamlScenario(t *testing.T, s formatScenario) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user