From c6b86225e3a5773a77a759c94503cbc079ea0f0a Mon Sep 17 00:00:00 2001 From: "Jose A. Rivera" Date: Mon, 3 Apr 2017 14:20:41 -0500 Subject: oc_label: handle case where _get() returns no results Signed-off-by: Jose A. Rivera --- roles/lib_openshift/library/oc_label.py | 4 ++-- roles/lib_openshift/src/class/oc_label.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'roles') diff --git a/roles/lib_openshift/library/oc_label.py b/roles/lib_openshift/library/oc_label.py index 62b6049c4..5fbbabe4f 100644 --- a/roles/lib_openshift/library/oc_label.py +++ b/roles/lib_openshift/library/oc_label.py @@ -1551,9 +1551,9 @@ class OCLabel(OpenShiftCLI): label_list = [] if self.name: - result = self._get(resource=self.kind, rname=self.name, selector=self.selector) + result = self._get(resource=self.kind, rname=self.name) - if 'labels' in result['results'][0]['metadata']: + if result['results'][0] and 'labels' in result['results'][0]['metadata']: label_list.append(result['results'][0]['metadata']['labels']) else: label_list.append({}) diff --git a/roles/lib_openshift/src/class/oc_label.py b/roles/lib_openshift/src/class/oc_label.py index bd312c170..ed17eecb1 100644 --- a/roles/lib_openshift/src/class/oc_label.py +++ b/roles/lib_openshift/src/class/oc_label.py @@ -134,9 +134,9 @@ class OCLabel(OpenShiftCLI): label_list = [] if self.name: - result = self._get(resource=self.kind, rname=self.name, selector=self.selector) + result = self._get(resource=self.kind, rname=self.name) - if 'labels' in result['results'][0]['metadata']: + if result['results'][0] and 'labels' in result['results'][0]['metadata']: label_list.append(result['results'][0]['metadata']['labels']) else: label_list.append({}) -- cgit v1.2.3