Don't require files key in env-generator

We have environments that are exclusively resource_registry entries,
and we shouldn't have to include a dummy files: key to make that
work with the generator.

Change-Id: I8ffabb5e583aabbfa4f2f22a4418783c857118fa
This commit is contained in:
Ben Nemec 2018-07-20 17:14:48 -05:00
parent 959e1d7f75
commit 1e8577e858
2 changed files with 23 additions and 1 deletions

View File

@ -82,7 +82,7 @@ def _generate_environment(input_env, output_path, parent_env=None):
param_names = defaultdict(list)
sample_values = env.get('sample_values', {})
static_names = env.get('static', [])
for template_file, template_data in env['files'].items():
for template_file, template_data in env.get('files', {}).items():
with open(template_file) as f:
f_data = yaml.safe_load(f)
f_params = f_data['parameters']

View File

@ -698,6 +698,25 @@ parameter_defaults:
# *********************
# End static parameters
# *********************
''',
}),
('no-files',
{'template': basic_template,
'exception': None,
'nested_output': '',
'input_file': '''environments:
-
name: basic
title: Basic Environment
description: Basic description
resource_registry:
foo: bar
''',
'expected_output': '''# title: Basic Environment
# description: |
# Basic description
resource_registry:
foo: bar
''',
}),
]
@ -715,6 +734,9 @@ parameter_defaults:
with mock.patch('tripleo_heat_templates.environment_generator.open',
create=True) as mock_open:
mock_se = [fake_input, fake_template, fake_output]
if 'files:' not in self.input_file:
# No files were specified so that open call won't happen
mock_se.remove(fake_template)
if self.nested_output:
_, fake_nested_output_path = tempfile.mkstemp()
fake_nested_output = open(fake_nested_output_path, 'w')