diff --git a/internal/template/reflect.go b/internal/template/reflect.go index 6a5f3b9b..f329f28d 100644 --- a/internal/template/reflect.go +++ b/internal/template/reflect.go @@ -41,24 +41,7 @@ func deepGetImpl(v reflect.Value, path []string) interface{} { case reflect.Struct: return deepGetImpl(v.FieldByName(path[0]), path[1:]) case reflect.Map: - // If the first part of the path is a key in the map, we use it directly - if mapValue := v.MapIndex(reflect.ValueOf(path[0])); mapValue.IsValid() { - return deepGetImpl(mapValue, path[1:]) - } - - // If the first part of the path is not a key in the map, we try to find a valid key by joining the path parts - for i := 2; i <= len(path); i++ { - joinedPath := strings.Join(path[0:i], ".") - if mapValue := v.MapIndex(reflect.ValueOf(joinedPath)); mapValue.IsValid() { - if i == len(path) { - return mapValue.Interface() - } - return deepGetImpl(mapValue, path[i:]) - } - } - - log.Printf("unable to find key from the path expression %s in map %v\n", strings.Join(path, "."), v) - return nil + return deepGetImpl(v.MapIndex(reflect.ValueOf(path[0])), path[1:]) case reflect.Slice, reflect.Array: i, err := parseAllocateInt(path[0]) if err != nil { diff --git a/internal/template/reflect_test.go b/internal/template/reflect_test.go index 5246fb31..2c43eb3b 100644 --- a/internal/template/reflect_test.go +++ b/internal/template/reflect_test.go @@ -74,28 +74,6 @@ func TestDeepGet(t *testing.T) { "...", "foo", }, - { - "map with dot in key", - map[string]map[string]string{ - "Foo": { - "foo.bar.baz.qux": "quux", - }, - }, - "Foo.foo.bar.baz.qux", - "quux", - }, - { - "nested maps with dot in keys", - map[string]map[string]map[string]string{ - "Foo": { - "foo.bar": { - "baz.qux": "quux", - }, - }, - }, - "Foo.foo.bar.baz.qux", - "quux", - }, {"struct", s, "X", "foo"}, {"pointer to struct", sp, "X", "foo"}, {"double pointer to struct", &sp, ".X", nil},