mirror of
https://github.com/mikefarah/yq.git
synced 2026-07-05 12:10:37 +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.Value = aliasNode.Value.String()
|
||||||
o.Alias = anchorMap[o.Value]
|
o.Alias = anchorMap[o.Value]
|
||||||
|
|
||||||
|
case ast.MergeKeyType:
|
||||||
|
log.Debugf("UnmarshalYAML - a merge key")
|
||||||
|
o.Kind = ScalarNode
|
||||||
|
o.Value = "<<"
|
||||||
|
|
||||||
default:
|
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)
|
log.Debugf("KIND: %v", o.Kind)
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -78,9 +78,6 @@ func (o *CandidateNode) copyToYamlNode(node *yaml.Node) {
|
|||||||
node.Value = o.Value
|
node.Value = o.Value
|
||||||
node.Anchor = o.Anchor
|
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.HeadComment = o.HeadComment
|
||||||
|
|
||||||
node.LineComment = o.LineComment
|
node.LineComment = o.LineComment
|
||||||
|
|||||||
@ -219,12 +219,24 @@ var goccyYamlFormatScenarios = []formatScenario{
|
|||||||
// expression: "explode(.)",
|
// expression: "explode(.)",
|
||||||
// expected: "a: mike\nb: mike\n",
|
// 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,
|
skipDoc: true,
|
||||||
input: "a: &remember mike\n---\nb: *remember",
|
input: "a: !cat mike",
|
||||||
expression: "explode(.)",
|
expected: "a: !cat mike\n",
|
||||||
expected: "a: mike\n---\nb: mike\n",
|
|
||||||
},
|
},
|
||||||
// {
|
// {
|
||||||
// description: "basic - [~]",
|
// description: "basic - [~]",
|
||||||
@ -256,6 +268,7 @@ var goccyYamlFormatScenarios = []formatScenario{
|
|||||||
// input: "[1, 2]",
|
// input: "[1, 2]",
|
||||||
// expected: "[1, 2]\n",
|
// expected: "[1, 2]\n",
|
||||||
// },
|
// },
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func testGoccyYamlScenario(t *testing.T, s formatScenario) {
|
func testGoccyYamlScenario(t *testing.T, s formatScenario) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user