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_utils/library | |
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_utils/library')
-rw-r--r-- | roles/lib_utils/library/yedit.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/roles/lib_utils/library/yedit.py b/roles/lib_utils/library/yedit.py index b1d9d6869..a2ae6b4f6 100644 --- a/roles/lib_utils/library/yedit.py +++ b/roles/lib_utils/library/yedit.py @@ -311,7 +311,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] @@ -320,7 +321,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 @@ -334,6 +335,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 |