summaryrefslogtreecommitdiff
path: root/cloudinit/handlers/cloud_config.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/handlers/cloud_config.py')
-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)