Skip to content

Commit

Permalink
Fix exception with empty resource list (#381)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
Gil8513 and fabianvf authored Sep 29, 2020
1 parent 55aa513 commit 09e63e8
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions openshift/dynamic/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,12 @@ def __init__(self, client, instance):
kind = instance['kind']
if kind.endswith('List') and 'items' in instance:
kind = instance['kind'][:-4]
for item in instance['items']:
if 'apiVersion' not in item:
item['apiVersion'] = instance['apiVersion']
if 'kind' not in item:
item['kind'] = kind
if instance['items']:
for item in instance['items']:
if 'apiVersion' not in item:
item['apiVersion'] = instance['apiVersion']
if 'kind' not in item:
item['kind'] = kind

self.attributes = self.__deserialize(instance)
self.__initialised = True
Expand Down

0 comments on commit 09e63e8

Please sign in to comment.