mirror of
https://github.com/mikefarah/yq.git
synced 2025-02-05 17:50:17 +00:00
Fixed explode for aliases to scalars
This commit is contained in:
parent
d40ad9649d
commit
72cd3e4a2a
@ -322,6 +322,21 @@ pointer: *value-pointer`
|
|||||||
test.AssertResult(t, expectedOutput, result.Output)
|
test.AssertResult(t, expectedOutput, result.Output)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestReadMergeAnchorsExplodeSimpleValueForValueCmd(t *testing.T) {
|
||||||
|
content := `value: &value-pointer the value
|
||||||
|
pointer: *value-pointer`
|
||||||
|
filename := test.WriteTempYamlFile(content)
|
||||||
|
defer test.RemoveTempYamlFile(filename)
|
||||||
|
|
||||||
|
cmd := getRootCommand()
|
||||||
|
result := test.RunCmd(cmd, fmt.Sprintf("read -X %s value", filename))
|
||||||
|
if result.Error != nil {
|
||||||
|
t.Error(result.Error)
|
||||||
|
}
|
||||||
|
expectedOutput := `the value`
|
||||||
|
test.AssertResult(t, expectedOutput, result.Output)
|
||||||
|
}
|
||||||
|
|
||||||
func TestReadMergeAnchorsExplodeCmd(t *testing.T) {
|
func TestReadMergeAnchorsExplodeCmd(t *testing.T) {
|
||||||
cmd := getRootCommand()
|
cmd := getRootCommand()
|
||||||
result := test.RunCmd(cmd, "read -X ../examples/merge-anchor.yaml")
|
result := test.RunCmd(cmd, "read -X ../examples/merge-anchor.yaml")
|
||||||
|
@ -31,10 +31,16 @@ func (n *navigator) Traverse(value *yaml.Node, path []string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (n *navigator) doTraverse(value *yaml.Node, head string, tail []string, pathStack []interface{}) error {
|
func (n *navigator) doTraverse(value *yaml.Node, head string, tail []string, pathStack []interface{}) error {
|
||||||
|
|
||||||
|
if value.Kind == yaml.ScalarNode {
|
||||||
|
return n.navigationStrategy.Visit(NewNodeContext(value, head, tail, pathStack))
|
||||||
|
}
|
||||||
|
|
||||||
log.Debug("head %v", head)
|
log.Debug("head %v", head)
|
||||||
DebugNode(value)
|
DebugNode(value)
|
||||||
|
|
||||||
var errorDeepSplatting error
|
var errorDeepSplatting error
|
||||||
if head == "**" && value.Kind != yaml.ScalarNode {
|
if head == "**" {
|
||||||
if len(pathStack) == 0 || pathStack[len(pathStack)-1] != "<<" {
|
if len(pathStack) == 0 || pathStack[len(pathStack)-1] != "<<" {
|
||||||
errorDeepSplatting = n.recurse(value, head, tail, pathStack)
|
errorDeepSplatting = n.recurse(value, head, tail, pathStack)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user