From d071b3dcc37958b32b16b1d09422e7299a1e83cb Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Wed, 10 Jul 2013 14:45:48 +1200 Subject: Make merge.py output deterministic. The current code uses dictionary sort order which is defined as being an undefined order. Since humans review .yaml files having them sorted is a good thing. Change-Id: I43a31530bc042750448ac904c0c22f9a59b09b4d --- merge.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'merge.py') diff --git a/merge.py b/merge.py index e0a5645c..afb6b222 100644 --- a/merge.py +++ b/merge.py @@ -38,7 +38,7 @@ for template_path in templates: end_template['Description'].append(template.get('Description', template_path)) new_parameters = template.get('Parameters', {}) - for p, pbody in iter(new_parameters.items()): + for p, pbody in sorted(new_parameters.items()): if p in end_template.get('Parameters', {}): if pbody != end_template['Parameters'][p]: errors.append('Parameter %s from %s conflicts.' % (p, @@ -49,7 +49,7 @@ for template_path in templates: end_template['Parameters'][p] = pbody new_outputs = template.get('Outputs', {}) - for o, obody in iter(new_outputs.items()): + for o, obody in sorted(new_outputs.items()): if o in end_template.get('Outputs', {}): if pbody != end_template['Outputs'][p]: errors.append('Output %s from %s conflicts.' % (o, @@ -60,7 +60,7 @@ for template_path in templates: end_template['Outputs'][o] = obody new_resources = template.get('Resources', {}) - for r, rbody in iter(new_resources.items()): + for r, rbody in sorted(new_resources.items()): if rbody['Type'] == 'AWS::EC2::Instance': # XXX Assuming ImageId is always a Ref del end_template['Parameters'][rbody['Properties']['ImageId']['Ref']] @@ -100,7 +100,7 @@ for template_path in templates: def fix_ref(item, old, new): if isinstance(item, dict): copy_item = dict(item) - for k, v in iter(copy_item.items()): + for k, v in sorted(copy_item.items()): if k == 'Ref' and v == old: item[k] = new continue -- cgit 1.2.3-korg