From 0be217f4c177a34b5ec46aa3e64fb1bede4ceb33 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Sat, 20 Jul 2013 07:34:31 -0700 Subject: Remove json-patch inclusion header if payload contains it. --- cloudinit/handlers/cloud_config.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'cloudinit/handlers') diff --git a/cloudinit/handlers/cloud_config.py b/cloudinit/handlers/cloud_config.py index 99dc71d0..654314c0 100644 --- a/cloudinit/handlers/cloud_config.py +++ b/cloudinit/handlers/cloud_config.py @@ -114,6 +114,12 @@ class CloudConfigPartHandler(handlers.Handler): return (payload_yaml, all_mergers) def _merge_patch(self, payload): + if payload.startswith("#json-patch"): + # 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[len("#json-patch"):] 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) -- cgit v1.2.3