Don't set any type on input config default
The default type for input was set to string, but it actually don't match what's used for the type property. Set it to ANY to let the user provide the proper value. Change-Id: I87edc0d8f1fba2fb61276c682a60c1b2241b5705 Closes-Bug: #1687643
This commit is contained in:
parent
358ca81517
commit
4f7036bdcb
|
@ -16,12 +16,14 @@ APIs for dealing with input and output definitions for Software Configurations.
|
|||
"""
|
||||
|
||||
import collections
|
||||
import copy
|
||||
import six
|
||||
|
||||
from heat.common.i18n import _
|
||||
|
||||
from heat.common import exception
|
||||
from heat.engine import constraints
|
||||
from heat.engine import parameters
|
||||
from heat.engine import properties
|
||||
|
||||
|
||||
|
@ -59,7 +61,7 @@ input_config_schema = {
|
|||
constraints=[constraints.AllowedValues(TYPES)]
|
||||
),
|
||||
DEFAULT: properties.Schema(
|
||||
properties.Schema.STRING,
|
||||
properties.Schema.ANY,
|
||||
_('Default value for the input if none is specified.'),
|
||||
),
|
||||
REPLACE_ON_CHANGE: properties.Schema(
|
||||
|
@ -126,6 +128,12 @@ class InputConfig(IOConfig):
|
|||
schema = input_config_schema
|
||||
|
||||
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)
|
||||
super(InputConfig, self).__init__(**config)
|
||||
self._value = value
|
||||
|
||||
|
|
|
@ -944,11 +944,11 @@ class SoftwareConfigIOSchemaTest(common.HeatTestCase):
|
|||
name = 'bar'
|
||||
inp = swc_io.InputConfig(name=name, description='test', type='Number',
|
||||
default=0, replace_on_change=True)
|
||||
self.assertEqual('0', inp.default())
|
||||
self.assertEqual(0, inp.default())
|
||||
self.assertIs(True, inp.replace_on_change())
|
||||
self.assertEqual(name, inp.name())
|
||||
self.assertEqual({'name': name, 'type': 'Number',
|
||||
'description': 'test', 'default': '0',
|
||||
'description': 'test', 'default': 0,
|
||||
'replace_on_change': True},
|
||||
inp.as_dict())
|
||||
self.assertEqual((name, None), inp.input_data())
|
||||
|
@ -957,11 +957,11 @@ class SoftwareConfigIOSchemaTest(common.HeatTestCase):
|
|||
name = 'baz'
|
||||
inp = swc_io.InputConfig(name=name, type='Number',
|
||||
default=0, value=42)
|
||||
self.assertEqual('0', inp.default())
|
||||
self.assertEqual(0, inp.default())
|
||||
self.assertIs(False, inp.replace_on_change())
|
||||
self.assertEqual(name, inp.name())
|
||||
self.assertEqual({'name': name, 'type': 'Number',
|
||||
'default': '0', 'value': 42},
|
||||
'default': 0, 'value': 42},
|
||||
inp.as_dict())
|
||||
self.assertEqual((name, 42), inp.input_data())
|
||||
|
||||
|
@ -1041,3 +1041,15 @@ class SoftwareConfigIOSchemaTest(common.HeatTestCase):
|
|||
def test_check_io_schema_list_mixed(self):
|
||||
self.assertRaises(TypeError, swc_io.check_io_schema_list,
|
||||
[{'name': 'foo'}, ('name', 'bar')])
|
||||
|
||||
def test_input_config_value_json_default(self):
|
||||
name = 'baz'
|
||||
inp = swc_io.InputConfig(name=name, type='Json',
|
||||
default={'a': 1}, value=42)
|
||||
self.assertEqual({'a': 1}, inp.default())
|
||||
|
||||
def test_input_config_value_default_coerce(self):
|
||||
name = 'baz'
|
||||
inp = swc_io.InputConfig(name=name, type='Number',
|
||||
default='0')
|
||||
self.assertEqual(0, inp.default())
|
||||
|
|
Loading…
Reference in New Issue