diff --git a/datamodel/high/node_builder.go b/datamodel/high/node_builder.go index 71b87507..0a71b089 100644 --- a/datamodel/high/node_builder.go +++ b/datamodel/high/node_builder.go @@ -627,30 +627,32 @@ func (n *NodeBuilder) extractLowMapKeysWrapped(iu reflect.Value, x string, order } func (n *NodeBuilder) extractLowMapKeys(fg reflect.Value, x string, found bool, orderedCollection []*NodeEntry, m reflect.Value, k reflect.Value) (bool, []*NodeEntry) { - for j, ky := range fg.MapKeys() { - hu := ky.Interface() - if we, wok := hu.(low.HasKeyNode); wok { - er := we.GetKeyNode().Value - if er == x { - found = true - orderedCollection = append(orderedCollection, &NodeEntry{ - Tag: x, - Key: x, - Line: we.GetKeyNode().Line, - Value: m.MapIndex(k).Interface(), - }) - } - } else { - uu := ky.Interface() - if uu == x { - // this is a map, without any low level details available - found = true - orderedCollection = append(orderedCollection, &NodeEntry{ - Tag: uu.(string), - Key: uu.(string), - Line: 9999 + j, - Value: m.MapIndex(k).Interface(), - }) + if !fg.IsZero() { + for j, ky := range fg.MapKeys() { + hu := ky.Interface() + if we, wok := hu.(low.HasKeyNode); wok { + er := we.GetKeyNode().Value + if er == x { + found = true + orderedCollection = append(orderedCollection, &NodeEntry{ + Tag: x, + Key: x, + Line: we.GetKeyNode().Line, + Value: m.MapIndex(k).Interface(), + }) + } + } else { + uu := ky.Interface() + if uu == x { + // this is a map, without any low level details available + found = true + orderedCollection = append(orderedCollection, &NodeEntry{ + Tag: uu.(string), + Key: uu.(string), + Line: 9999 + j, + Value: m.MapIndex(k).Interface(), + }) + } } } } diff --git a/go.sum b/go.sum index 026d1375..67087946 100644 --- a/go.sum +++ b/go.sum @@ -58,8 +58,6 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= -github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/vmware-labs/yaml-jsonpath v0.3.2 h1:/5QKeCBGdsInyDCyVNLbXyilb61MXGi9NP674f9Hobk= github.com/vmware-labs/yaml-jsonpath v0.3.2/go.mod h1:U6whw1z03QyqgWdgXxvVnQ90zN1BWz5V+51Ewf8k+rQ= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -80,8 +78,6 @@ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= -golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=