Log a warning when boolean is found in environment

We're going to warn people that allowing a boolean in the environment is
being deprecated, so in a future release we can disallow it. This is to
ensure boolean variables are quoted in strings to ensure they don't get
mis-parsed by YML.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
This commit is contained in:
Mazz Mosley 2015-09-10 16:25:54 +01:00
commit 8caeffe27e
3 changed files with 42 additions and 18 deletions

View file

@ -270,20 +270,22 @@ class ConfigTest(unittest.TestCase):
)
self.assertEqual(service[0]['entrypoint'], entrypoint)
def test_config_environment_contains_boolean_validation_error(self):
expected_error_msg = "Service 'web' configuration key 'environment' contains an invalid type"
with self.assertRaisesRegexp(ConfigurationError, expected_error_msg):
config.load(
config.ConfigDetails(
{'web': {
'image': 'busybox',
'environment': {'SHOW_STUFF': True}
}},
'working_dir',
'filename.yml'
)
@mock.patch('compose.config.validation.log')
def test_logs_warning_for_boolean_in_environment(self, mock_logging):
expected_warning_msg = "Warning: There is a boolean value, True in the 'environment' key."
config.load(
config.ConfigDetails(
{'web': {
'image': 'busybox',
'environment': {'SHOW_STUFF': True}
}},
'working_dir',
'filename.yml'
)
)
self.assertTrue(mock_logging.warn.called)
self.assertTrue(expected_warning_msg in mock_logging.warn.call_args[0][0])
class InterpolationTest(unittest.TestCase):