Skip to content

Commit 09e63e8

Browse files
Gil8513fabianvf
andauthored
Fix exception with empty resource list (#381)
* Fix exception with empty resource list Fix exception that occurs when query returns empty resource list. Iterate over the list items only if it is not None. * Add missing end quote Co-authored-by: Fabian von Feilitzsch <[email protected]>
1 parent 55aa513 commit 09e63e8

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

openshift/dynamic/resource.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,12 @@ def __init__(self, client, instance):
276276
kind = instance['kind']
277277
if kind.endswith('List') and 'items' in instance:
278278
kind = instance['kind'][:-4]
279-
for item in instance['items']:
280-
if 'apiVersion' not in item:
281-
item['apiVersion'] = instance['apiVersion']
282-
if 'kind' not in item:
283-
item['kind'] = kind
279+
if instance['items']:
280+
for item in instance['items']:
281+
if 'apiVersion' not in item:
282+
item['apiVersion'] = instance['apiVersion']
283+
if 'kind' not in item:
284+
item['kind'] = kind
284285

285286
self.attributes = self.__deserialize(instance)
286287
self.__initialised = True

0 commit comments

Comments
 (0)