@@ -194,32 +194,33 @@ func (ip *InformersMap) Get(gvk schema.GroupVersionKind, obj runtime.Object) (*M
194
194
195
195
// newListWatch returns a new ListWatch object that can be used to create a SharedIndexInformer.
196
196
func (ip * InformersMap ) newListWatch (gvk schema.GroupVersionKind , isUnstructured bool ) (* cache.ListWatch , error ) {
197
- // Construct a RESTClient for the groupVersionKind that we will use to
198
- // talk to the apiserver.
199
- var client rest.Interface
200
- var err error
201
- if isUnstructured {
202
- client , err = apiutil .RESTUnstructuredClientForGVK (gvk , ip .config )
203
- } else {
204
- client , err = apiutil .RESTClientForGVK (gvk , ip .config , ip .codecs )
205
-
206
- }
207
- if err != nil {
208
- return nil , err
209
- }
210
-
211
197
// Kubernetes APIs work against Resources, not GroupVersionKinds. Map the
212
198
// groupVersionKind to the Resource API we will use.
213
199
mapping , err := ip .mapper .RESTMapping (gvk .GroupKind (), gvk .Version )
214
200
if err != nil {
215
201
return nil , err
216
202
}
217
203
218
- // Get a listObject for listing that the ListWatch can DeepCopy
219
- listGVK := gvk .GroupVersion ().WithKind (gvk .Kind + "List" )
220
- listObj , err := ip .Scheme .New (listGVK )
221
- if err != nil {
222
- return nil , err
204
+ // Construct a RESTClient for the groupVersionKind that we will use to
205
+ // talk to the apiserver.
206
+ var client rest.Interface
207
+ var listObj runtime.Object
208
+ if isUnstructured {
209
+ listObj = & unstructured.UnstructuredList {}
210
+ client , err = apiutil .RESTUnstructuredClientForGVK (gvk , ip .config )
211
+ if err != nil {
212
+ return nil , err
213
+ }
214
+ } else {
215
+ client , err = apiutil .RESTClientForGVK (gvk , ip .config , ip .codecs )
216
+ if err != nil {
217
+ return nil , err
218
+ }
219
+ listGVK := gvk .GroupVersion ().WithKind (gvk .Kind + "List" )
220
+ listObj , err = ip .Scheme .New (listGVK )
221
+ if err != nil {
222
+ return nil , err
223
+ }
223
224
}
224
225
225
226
// Create a new ListWatch for the obj
0 commit comments