Skip to content

Commit f329213

Browse files
Misc. fixes
1 parent 4dcc02a commit f329213

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

pkg/util/template.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ func lookup(path string, input interface{}) interface{} {
226226
obj := reflect.ValueOf(input)
227227

228228
components := strings.Split(path, ".")
229+
229230
for i := 0; i < len(components); {
230231
component := components[i]
231232

@@ -240,8 +241,8 @@ func lookup(path string, input interface{}) interface{} {
240241
// Get the thing being pointed to or interfaced, don't advance index
241242
obj = obj.Elem()
242243
default:
243-
obj = zeroValue
244-
break
244+
// Got an unexpected type
245+
return nil
245246
}
246247
}
247248

pkg/util/template_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ func TestLookup(t *testing.T) {
169169
assert.Equal(t, "value0", lookup("Key", s))
170170
assert.Equal(t, nil, lookup("bad-key", s))
171171
assert.Equal(t, nil, lookup("", s))
172+
assert.Equal(t, nil, lookup("key", "not a map"))
172173
assert.Equal(t, "value1", lookup("Inner.Map.key1", s))
173174
assert.Equal(t, "value1", lookup("Inner.Map.key1", &s))
174175
assert.Equal(t, "value4", lookup("Inner.Map.key2.key3.key4", s))

0 commit comments

Comments
 (0)