Ignore string default for software config input
We recently (I87edc0d8f1fba2fb61276c682a60c1b2241b5705) enforced default type for software config input, whereas it was always a string before. It causes issues with upgrades, as we used to store "" as a default for all configs regarless of their type, and it failed when we started validating. This identifies this case and skip validation. Change-Id: I8a4f4e834b0862ecef4b97f208f4b03be3572e86 Closes-Bug: #1697627changes/17/475817/1
parent
a5ac2c3b1d
commit
f911ebbd67
|
@ -129,11 +129,16 @@ class InputConfig(IOConfig):
|
|||
|
||||
def __init__(self, value=_no_value, **config):
|
||||
if TYPE in config and DEFAULT in config:
|
||||
self.schema = copy.deepcopy(self.schema)
|
||||
config_param = parameters.Schema.from_dict(
|
||||
'config', {'Type': config[TYPE]})
|
||||
self.schema[DEFAULT] = properties.Schema.from_parameter(
|
||||
config_param)
|
||||
if config[DEFAULT] == '' and config[TYPE] != STRING_TYPE:
|
||||
# This is a legacy path, because default used to be of string
|
||||
# type, so we need to skip schema validation in this case.
|
||||
pass
|
||||
else:
|
||||
self.schema = copy.deepcopy(self.schema)
|
||||
config_param = parameters.Schema.from_dict(
|
||||
'config', {'Type': config[TYPE]})
|
||||
self.schema[DEFAULT] = properties.Schema.from_parameter(
|
||||
config_param)
|
||||
super(InputConfig, self).__init__(**config)
|
||||
self._value = value
|
||||
|
||||
|
|
|
@ -1058,3 +1058,11 @@ class SoftwareConfigIOSchemaTest(common.HeatTestCase):
|
|||
inp = swc_io.InputConfig(name=name, type='Number',
|
||||
default='0')
|
||||
self.assertEqual(0, inp.default())
|
||||
|
||||
def test_input_config_value_ignore_string(self):
|
||||
name = 'baz'
|
||||
inp = swc_io.InputConfig(name=name, type='Number',
|
||||
default='')
|
||||
|
||||
self.assertEqual({'type': 'Number', 'name': 'baz', 'default': ''},
|
||||
inp.as_dict())
|
||||
|
|
Loading…
Reference in New Issue