Browse Source

oc_obj: only check 'items' if exists in delete

Signed-off-by: Jose A. Rivera <jarrpa@redhat.com>
Jose A. Rivera 7 years ago
parent
commit
e089f74edc
2 changed files with 4 additions and 2 deletions
  1. 2 1
      roles/lib_openshift/library/oc_obj.py
  2. 2 1
      roles/lib_openshift/src/class/oc_obj.py

+ 2 - 1
roles/lib_openshift/library/oc_obj.py

@@ -1557,7 +1557,8 @@ class OCObject(OpenShiftCLI):
         if state == 'absent':
             # verify its not in our results
             if (params['name'] is not None or params['selector'] is not None) and \
-               (len(api_rval['results']) == 0 or len(api_rval['results'][0].get('items', [])) == 0):
+               (len(api_rval['results']) == 0 or \
+               ('items' in api_rval['results'][0] and len(api_rval['results'][0]['items']) == 0)):
                 return {'changed': False, 'state': state}
 
             if check_mode:

+ 2 - 1
roles/lib_openshift/src/class/oc_obj.py

@@ -117,7 +117,8 @@ class OCObject(OpenShiftCLI):
         if state == 'absent':
             # verify its not in our results
             if (params['name'] is not None or params['selector'] is not None) and \
-               (len(api_rval['results']) == 0 or len(api_rval['results'][0].get('items', [])) == 0):
+               (len(api_rval['results']) == 0 or \
+               ('items' in api_rval['results'][0] and len(api_rval['results'][0]['items']) == 0)):
                 return {'changed': False, 'state': state}
 
             if check_mode: