diff --git a/pkg/yqlib/candidate_node_goccy_yaml.go b/pkg/yqlib/candidate_node_goccy_yaml.go index 284be990..4a0f47b1 100644 --- a/pkg/yqlib/candidate_node_goccy_yaml.go +++ b/pkg/yqlib/candidate_node_goccy_yaml.go @@ -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 diff --git a/pkg/yqlib/candidate_node_yaml.go b/pkg/yqlib/candidate_node_yaml.go index 67f57a48..c80af2a2 100644 --- a/pkg/yqlib/candidate_node_yaml.go +++ b/pkg/yqlib/candidate_node_yaml.go @@ -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 diff --git a/pkg/yqlib/goccy_yaml_test.go b/pkg/yqlib/goccy_yaml_test.go index 01d66255..8389e913 100644 --- a/pkg/yqlib/goccy_yaml_test.go +++ b/pkg/yqlib/goccy_yaml_test.go @@ -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) {