summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@gmail.com>2013-07-20 07:34:31 -0700
committerJoshua Harlow <harlowja@gmail.com>2013-07-20 07:34:31 -0700
commit0be217f4c177a34b5ec46aa3e64fb1bede4ceb33 (patch)
tree2f43ec0420b6cbe2f92876d601ab2449e41e6645
parent1f73904df31feb22ad8545a3a336ba2e92e367bb (diff)
downloadvyos-cloud-init-0be217f4c177a34b5ec46aa3e64fb1bede4ceb33.tar.gz
vyos-cloud-init-0be217f4c177a34b5ec46aa3e64fb1bede4ceb33.zip
Remove json-patch inclusion header if payload contains it.
-rw-r--r--cloudinit/handlers/cloud_config.py6
1 files changed, 6 insertions, 0 deletions
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)