summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Collins <rbtcollins@hp.com>2013-07-10 14:45:48 +1200
committerRobert Collins <rbtcollins@hp.com>2013-07-10 14:45:48 +1200
commitd071b3dcc37958b32b16b1d09422e7299a1e83cb (patch)
tree22a95027ef189d188fddaf50f869ce66c338e3f4
parent688a489021b0ca53c0aebfc7e843ddef5a922f6f (diff)
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
-rw-r--r--merge.py8
1 files changed, 4 insertions, 4 deletions
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