summaryrefslogtreecommitdiff
path: root/puppet/modules/couchdb/files/couch-doc-diff
diff options
context:
space:
mode:
authorMicah <micah@leap.se>2016-05-24 10:19:27 -0400
committerMicah <micah@leap.se>2016-05-24 10:19:27 -0400
commit8f1fd7c7e042539f3095541b8859276e4dad6629 (patch)
tree864440ba7ce27d8d1fc8d7a504d554bb2fcd2817 /puppet/modules/couchdb/files/couch-doc-diff
parent9721c9eeb21f027456b149764d300a11e301c8ee (diff)
parentaf6fdd31fb961fc1b7f408f51001e7a6d192a58a (diff)
Merge commit 'af6fdd31fb961fc1b7f408f51001e7a6d192a58a' as 'puppet/modules/couchdb'
Diffstat (limited to 'puppet/modules/couchdb/files/couch-doc-diff')
-rw-r--r--puppet/modules/couchdb/files/couch-doc-diff17
1 files changed, 17 insertions, 0 deletions
diff --git a/puppet/modules/couchdb/files/couch-doc-diff b/puppet/modules/couchdb/files/couch-doc-diff
new file mode 100644
index 00000000..a5907d5e
--- /dev/null
+++ b/puppet/modules/couchdb/files/couch-doc-diff
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+# Run a diff between a couch document specified as the first parameter
+# and the second parameter.
+# Diff returns 0 if there is no difference. This way you can tell the data
+# is already on the couch.
+# Both the couch document and the second paramter will be pretty printed
+# before comparison so differences in spaces etc. do not matter.
+# All keys starting with an underscore on the couch such as _id and _rev
+# will be removed before the comparison - we assume we want to compare
+# the real data, not the metadata about the document as we usually do not
+# know or care about what the id and revision will be.
+
+curl -s --netrc-file /etc/couchdb/couchdb.netrc $1 \
+ | python -mjson.tool \
+ | grep -v '^\s*"_' \
+ | diff -w - <(echo $2 | python -mjson.tool)