Fix setting defaults for 0
The check for the presence of a default was incorrect, causing values of 0 to be interpretted as no default and setting it to an empty string. This patch corrects the logic that checks for a default. Change-Id: I6f720346cbd7645ccbbbad96ddc24bc2757e3805
This commit is contained in:
parent
021b6a5752
commit
f156a59a4c
@ -226,7 +226,10 @@ class DeploymentPlan(object):
|
||||
continue
|
||||
|
||||
name = ns_utils.apply_template_namespace(namespace, add_me.name)
|
||||
env_parameter = EnvironmentParameter(name, add_me.default or '')
|
||||
param_default = add_me.default
|
||||
if param_default is None:
|
||||
param_default = ''
|
||||
env_parameter = EnvironmentParameter(name, param_default)
|
||||
self.environment.add_parameter(env_parameter)
|
||||
|
||||
if self.add_scaling:
|
||||
|
@ -92,6 +92,7 @@ class DeploymentPlanTests(unittest.TestCase):
|
||||
t = heat.Template()
|
||||
t.add_parameter(heat.Parameter('param-1', 'type-1', default='d1'))
|
||||
t.add_parameter(heat.Parameter('param-2', 'type-2'))
|
||||
t.add_parameter(heat.Parameter('param-3', 'type-3', default=0))
|
||||
p.add_template('ns1', t, 'template-1.yaml')
|
||||
|
||||
# Verify
|
||||
@ -105,6 +106,11 @@ class DeploymentPlanTests(unittest.TestCase):
|
||||
p2.name)
|
||||
self.assertEqual('', p2.value)
|
||||
|
||||
p3 = p.environment.parameters[2]
|
||||
self.assertEqual(ns_utils.apply_template_namespace('ns1', 'param-3'),
|
||||
p3.name)
|
||||
self.assertEqual(0, p3.value)
|
||||
|
||||
def test_add_template_with_colliding_namespace(self):
|
||||
# Test
|
||||
p = plan.DeploymentPlan()
|
||||
|
Loading…
x
Reference in New Issue
Block a user