Browse Source

Allow arrays in 'value' in environment_config.yaml

Since Fuel 9.0 we have a new type for environment attributes: "text_list".
In that case, attribute's value must be an array. FPB didn't handle that
case, and throws error for any case when value is array.

This patch add "array" as a valid type for "value". In order to keep
simplicity and do not overcomplicate JSON schema, it allows arrays for
all types, not only for "text_list". It's consistent with Nailgun code,
where we don't have such check either.

Change-Id: I2ab401e4cdc7c1a1eb276aa71253818c688fdca1
Closes-Bug: #1616466
Igor Kalnitsky 2 years ago
parent
commit
4cd808c39b

+ 15
- 0
fuel_plugin_builder/tests/test_validator_v4.py View File

@@ -148,6 +148,21 @@ class TestValidatorV4(TestValidatorV3):
148 148
             self.validator.check_env_config_attrs
149 149
         )
150 150
 
151
+    @mock.patch('fuel_plugin_builder.validators.base.utils')
152
+    def test_environment_config_type_attrs(self, utils_mock):
153
+        mock_data = {
154
+            'attributes': {
155
+                'server-name': {
156
+                    'value': [],
157
+                    'label': 'test',
158
+                    'weight': 1,
159
+                    'type': 'text_list',
160
+                }
161
+            }
162
+        }
163
+        utils_mock.parse_yaml.return_value = mock_data
164
+        self.assertEqual(None, self.validator.check_env_config_attrs())
165
+
151 166
     @mock.patch('fuel_plugin_builder.validators.base.utils')
152 167
     def test_check_components_schema_validation_failed(self, utils_mock):
153 168
         data_sets = [

+ 4
- 1
fuel_plugin_builder/validators/schemas/base.py View File

@@ -173,7 +173,10 @@ class BaseSchema(object):
173 173
                     {'type': 'string'},
174 174
                     {'type': 'boolean'},
175 175
                     {'type': 'object',
176
-                     'properties': {'generator': {'type': 'string'}}}
176
+                     'properties': {'generator': {'type': 'string'}}},
177
+                    {'type': 'array',
178
+                     'items': {'anyOf': [{'type': 'string'},
179
+                                         {'type': 'boolean'}]}},
177 180
                 ]},
178 181
                 'label': {'type': 'string'},
179 182
                 'restrictions': self.restrictions,

Loading…
Cancel
Save