diff options
author | Kenny Woodson <kwoodson@redhat.com> | 2017-03-03 09:45:35 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-03 09:45:35 -0500 |
commit | e2bc346fc99de637d03762b4b813b596afffc7dc (patch) | |
tree | a89e485eceadf6a3c4f9184b6de165492e79e685 /roles/lib_openshift/library/oadm_manage_node.py | |
parent | fc1c4f8ff769e8da5823494209d875a37483a01e (diff) | |
parent | db11dec91ae2125c7ec19090dd4ea5449ecec09e (diff) | |
download | openshift-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/oadm_manage_node.py')
-rw-r--r-- | roles/lib_openshift/library/oadm_manage_node.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/roles/lib_openshift/library/oadm_manage_node.py b/roles/lib_openshift/library/oadm_manage_node.py index 0c29c1b91..8c0a29ac7 100644 --- a/roles/lib_openshift/library/oadm_manage_node.py +++ b/roles/lib_openshift/library/oadm_manage_node.py @@ -267,7 +267,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] @@ -276,7 +277,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 @@ -290,6 +291,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 |