Merge "Handle invalid depends field"
This commit is contained in:
commit
83e2646f85
|
@ -98,6 +98,14 @@ class CommonTemplate(template.Template):
|
|||
name, data, no_parse)
|
||||
if isinstance(depends, six.string_types):
|
||||
depends = [depends]
|
||||
elif depends:
|
||||
for dep in depends:
|
||||
if not isinstance(dep, six.string_types):
|
||||
msg = _('Resource %(name)s %(key)s '
|
||||
'must be a list of strings') % {
|
||||
'name': name, 'key': self.RES_DEPENDS_ON}
|
||||
raise exception.StackValidationFailed(message=msg)
|
||||
|
||||
yield 'depends', depends
|
||||
|
||||
del_policy = self._parse_resource_field(self.RES_DELETION_POLICY,
|
||||
|
|
|
@ -2105,3 +2105,21 @@ parameters:
|
|||
'NoEcho': 'false',
|
||||
'Type': 'String'}}}
|
||||
self.assertEqual(expected, res)
|
||||
|
||||
def test_validate_bad_depends(self):
|
||||
test_template = '''
|
||||
heat_template_version: 2013-05-23
|
||||
|
||||
resources:
|
||||
random_str:
|
||||
type: OS::Heat::RandomString
|
||||
depends_on: [{foo: bar}]
|
||||
'''
|
||||
|
||||
t = template_format.parse(test_template)
|
||||
|
||||
res = dict(self.engine.validate_template(self.ctx, t, {}))
|
||||
self.assertEqual(
|
||||
{'Error': 'Resource random_str depends_on must be '
|
||||
'a list of strings'},
|
||||
res)
|
||||
|
|
Loading…
Reference in New Issue