summaryrefslogtreecommitdiffstats
path: root/roles/lib_openshift/library/oc_adm_router.py
diff options
context:
space:
mode:
authorKenny Woodson <kwoodson@redhat.com>2017-03-03 09:45:35 -0500
committerGitHub <noreply@github.com>2017-03-03 09:45:35 -0500
commite2bc346fc99de637d03762b4b813b596afffc7dc (patch)
treea89e485eceadf6a3c4f9184b6de165492e79e685 /roles/lib_openshift/library/oc_adm_router.py
parentfc1c4f8ff769e8da5823494209d875a37483a01e (diff)
parentdb11dec91ae2125c7ec19090dd4ea5449ecec09e (diff)
downloadopenshift-e2bc346fc99de637d03762b4b813b596afffc7dc.tar.gz
openshift-e2bc346fc99de637d03762b4b813b596afffc7dc.tar.bz2
openshift-e2bc346fc99de637d03762b4b813b596afffc7dc.tar.xz
openshift-e2bc346fc99de637d03762b4b813b596afffc7dc.zip
Merge pull request #3527 from joelddiaz/yedit-path-exceptions
raise exceptions when walking through object path
Diffstat (limited to 'roles/lib_openshift/library/oc_adm_router.py')
-rw-r--r--roles/lib_openshift/library/oc_adm_router.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/roles/lib_openshift/library/oc_adm_router.py b/roles/lib_openshift/library/oc_adm_router.py
index bb4ce5e70..68b797577 100644
--- a/roles/lib_openshift/library/oc_adm_router.py
+++ b/roles/lib_openshift/library/oc_adm_router.py
@@ -396,7 +396,8 @@ class Yedit(object):
continue
elif data and not isinstance(data, dict):
- return None
+ raise YeditException("Unexpected item type found while going through key " +
+ "path: {} (at key: {})".format(key, dict_key))
data[dict_key] = {}
data = data[dict_key]
@@ -405,7 +406,7 @@ class Yedit(object):
int(arr_ind) <= len(data) - 1):
data = data[int(arr_ind)]
else:
- return None
+ raise YeditException("Unexpected item type found while going through key path: {}".format(key))
if key == '':
data = item
@@ -419,6 +420,12 @@ class Yedit(object):
elif key_indexes[-1][1] and isinstance(data, dict):
data[key_indexes[-1][1]] = item
+ # didn't add/update to an existing list, nor add/update key to a dict
+ # so we must have been provided some syntax like a.b.c[<int>] = "data" for a
+ # non-existent array
+ else:
+ raise YeditException("Error adding to object at path: {}".format(key))
+
return data
@staticmethod