Example #1
0
 def _get_difference(self, cfn, stack, data):
     """
     Helper method to find differences between two JSON documents
     """
     resp = cfn.get_template(stack)['GetTemplateResponse']
     old_body = resp['GetTemplateResult']['TemplateBody']
     return get_changed_keys_from_templates(old_body, data)
Example #2
0
 def _show_prompt(self, cfn, stack, data, allowed):
     """
     Helper method to create colourised diff outut and prompt for update
     """
     resp = cfn.get_template(stack)['GetTemplateResponse']
     old_body = resp['GetTemplateResult']['TemplateBody']
     diff = make_diff(old_body, data)
     if len(diff):
         print "Diff from previous:"
         print diff
         chkeys = get_changed_keys_from_templates(old_body, data)
         chkeys = [k for k in chkeys if not allowed.match(k)]
         print "Changed data:"
         for k in sorted(chkeys):
             print k
         answer = self._get_input("Continue? [Yn]: ")
         if answer.lower().startswith('n'):
             return False
     else:
         LOG.warning('No difference, not updating')
         return False
     return True
Example #3
0
 def test_get_changed_keys_from_templates_different_data(self):
     a = '{"a": [1, 2, 3]}'
     b = '{"a": [1, 2, 4]}'
     output = utils.get_changed_keys_from_templates(a, b)
     assert_equals(True, len(output) == 1)