Skip to content

Commit f024e45

Browse files
DewaldValvaroaleman
authored andcommitted
Construct pointer to cache type for non-pointers only.
When the list type is already a pointer this code results in a cache type of **Type which can't be cast to runtime.Object. This adds a check to the function to only grab a pointer to a type if it is not already a ptr type.
1 parent e00985b commit f024e45

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pkg/cache/informer_cache.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ func (ip *informerCache) List(ctx context.Context, out runtime.Object, opts ...c
9393
}
9494
// http://knowyourmeme.com/memes/this-is-fine
9595
elemType := reflect.Indirect(reflect.ValueOf(itemsPtr)).Type().Elem()
96-
cacheTypeValue := reflect.Zero(reflect.PtrTo(elemType))
96+
if elemType.Kind() != reflect.Ptr {
97+
elemType = reflect.PtrTo(elemType)
98+
}
99+
100+
cacheTypeValue := reflect.Zero(elemType)
97101
var ok bool
98102
cacheTypeObj, ok = cacheTypeValue.Interface().(runtime.Object)
99103
if !ok {

0 commit comments

Comments
 (0)