summaryrefslogtreecommitdiff
path: root/cloudinit/handlers
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@gmail.com>2013-07-24 08:39:03 -0700
committerJoshua Harlow <harlowja@gmail.com>2013-07-24 08:39:03 -0700
commit851906b6acde33fddcbdd1d41f366d6652d1e84d (patch)
tree0a715c1ee75bb730ae7f1e3dd6f1746413db801c /cloudinit/handlers
parent2939f498f51025ebd0c9bdf302b578dfcbf54d0c (diff)
downloadcloud-init-git-851906b6acde33fddcbdd1d41f366d6652d1e84d.tar.gz
Fix small prefix bug + jsonp tests.
Fix the wrong usage of the prefix removal array action by just using the new util function that does these actions correctly. Add in a couple of unit tests to verify the jsonp merging and usage works as expected.
Diffstat (limited to 'cloudinit/handlers')
-rw-r--r--cloudinit/handlers/cloud_config.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/cloudinit/handlers/cloud_config.py b/cloudinit/handlers/cloud_config.py
index 7edae13d..34a73115 100644
--- a/cloudinit/handlers/cloud_config.py
+++ b/cloudinit/handlers/cloud_config.py
@@ -116,13 +116,12 @@ class CloudConfigPartHandler(handlers.Handler):
return (payload_yaml, all_mergers)
def _merge_patch(self, payload):
+ # JSON doesn't handle comments in this manner, so ensure that
+ # if we started with this 'type' that we remove it before
+ # attempting to load it as json (which the jsonpatch library will
+ # attempt to do).
payload = payload.lstrip()
- if payload.lower().startswith(JSONP_PREFIX):
- # JSON doesn't handle comments in this manner, so ensure that
- # if we started with this 'type' that we remove it before
- # attempting to load it as json (which the jsonpatch library will
- # attempt to do).
- payload = payload[JSONP_PREFIX:]
+ payload = util.strip_prefix_suffix(payload, prefix=JSONP_PREFIX)
patch = jsonpatch.JsonPatch.from_string(payload)
LOG.debug("Merging by applying json patch %s", patch)
self.cloud_buf = patch.apply(self.cloud_buf, in_place=False)