Skip to content

Commit 832f376

Browse files
committed
Added zerocheck for node builder
was blowing up with some invalid specs. Signed-off-by: Dave Shanley <[email protected]>
1 parent f7a6c9d commit 832f376

2 files changed

Lines changed: 26 additions & 28 deletions

File tree

datamodel/high/node_builder.go

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -627,30 +627,32 @@ func (n *NodeBuilder) extractLowMapKeysWrapped(iu reflect.Value, x string, order
627627
}
628628

629629
func (n *NodeBuilder) extractLowMapKeys(fg reflect.Value, x string, found bool, orderedCollection []*NodeEntry, m reflect.Value, k reflect.Value) (bool, []*NodeEntry) {
630-
for j, ky := range fg.MapKeys() {
631-
hu := ky.Interface()
632-
if we, wok := hu.(low.HasKeyNode); wok {
633-
er := we.GetKeyNode().Value
634-
if er == x {
635-
found = true
636-
orderedCollection = append(orderedCollection, &NodeEntry{
637-
Tag: x,
638-
Key: x,
639-
Line: we.GetKeyNode().Line,
640-
Value: m.MapIndex(k).Interface(),
641-
})
642-
}
643-
} else {
644-
uu := ky.Interface()
645-
if uu == x {
646-
// this is a map, without any low level details available
647-
found = true
648-
orderedCollection = append(orderedCollection, &NodeEntry{
649-
Tag: uu.(string),
650-
Key: uu.(string),
651-
Line: 9999 + j,
652-
Value: m.MapIndex(k).Interface(),
653-
})
630+
if !fg.IsZero() {
631+
for j, ky := range fg.MapKeys() {
632+
hu := ky.Interface()
633+
if we, wok := hu.(low.HasKeyNode); wok {
634+
er := we.GetKeyNode().Value
635+
if er == x {
636+
found = true
637+
orderedCollection = append(orderedCollection, &NodeEntry{
638+
Tag: x,
639+
Key: x,
640+
Line: we.GetKeyNode().Line,
641+
Value: m.MapIndex(k).Interface(),
642+
})
643+
}
644+
} else {
645+
uu := ky.Interface()
646+
if uu == x {
647+
// this is a map, without any low level details available
648+
found = true
649+
orderedCollection = append(orderedCollection, &NodeEntry{
650+
Tag: uu.(string),
651+
Key: uu.(string),
652+
Line: 9999 + j,
653+
Value: m.MapIndex(k).Interface(),
654+
})
655+
}
654656
}
655657
}
656658
}

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
5858
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
5959
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
6060
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
61-
github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
62-
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
6361
github.com/vmware-labs/yaml-jsonpath v0.3.2 h1:/5QKeCBGdsInyDCyVNLbXyilb61MXGi9NP674f9Hobk=
6462
github.com/vmware-labs/yaml-jsonpath v0.3.2/go.mod h1:U6whw1z03QyqgWdgXxvVnQ90zN1BWz5V+51Ewf8k+rQ=
6563
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
8078
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
8179
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
8280
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
83-
golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=
84-
golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
8581
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
8682
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
8783
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

0 commit comments

Comments
 (0)