@@ -189,15 +189,23 @@ func (c *singleObjectCache) List(ctx context.Context, opts *ListOptions, out run
189
189
labelSel = opts .LabelSelector
190
190
}
191
191
192
+ outItems , err := c .getListItems (objs , labelSel )
193
+ if err != nil {
194
+ return err
195
+ }
196
+ return apimeta .SetList (out , outItems )
197
+ }
198
+
199
+ func (c * singleObjectCache ) getListItems (objs []interface {}, labelSel labels.Selector ) ([]runtime.Object , error ) {
192
200
outItems := make ([]runtime.Object , 0 , len (objs ))
193
201
for _ , item := range objs {
194
202
obj , isObj := item .(runtime.Object )
195
203
if ! isObj {
196
- return fmt .Errorf ("cache contained %T, which is not an Object" , obj )
204
+ return nil , fmt .Errorf ("cache contained %T, which is not an Object" , obj )
197
205
}
198
206
meta , err := apimeta .Accessor (obj )
199
207
if err != nil {
200
- return err
208
+ return nil , err
201
209
}
202
210
if labelSel != nil {
203
211
lbls := labels .Set (meta .GetLabels ())
@@ -207,7 +215,7 @@ func (c *singleObjectCache) List(ctx context.Context, opts *ListOptions, out run
207
215
}
208
216
outItems = append (outItems , obj .DeepCopyObject ())
209
217
}
210
- return apimeta . SetList ( out , outItems )
218
+ return outItems , nil
211
219
}
212
220
213
221
// TODO: Make an interface with this function that has an Informers as an object on the struct
0 commit comments