Fix warning about boolean values.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
Daniel Nephin 2016-02-22 14:48:56 -08:00
parent d5514965d5
commit 0a06d827fa
2 changed files with 7 additions and 7 deletions

View File

@ -64,16 +64,16 @@ def format_expose(instance):
@FormatChecker.cls_checks(format="bool-value-in-mapping") @FormatChecker.cls_checks(format="bool-value-in-mapping")
def format_boolean_in_environment(instance): def format_boolean_in_environment(instance):
""" """Check if there is a boolean in the mapping sections and display a warning.
Check if there is a boolean in the environment and display a warning.
Always return True here so the validation won't raise an error. Always return True here so the validation won't raise an error.
""" """
if isinstance(instance, bool): if isinstance(instance, bool):
log.warn( log.warn(
"There is a boolean value in the 'environment' key.\n" "There is a boolean value in the 'environment', 'labels', or "
"Environment variables can only be strings.\n" "'extra_hosts' field of a service.\n"
"Please add quotes to any boolean values to make them string " "These sections only support string values.\n"
"(eg, 'True', 'yes', 'N').\n" "Please add quotes to any boolean values to make them strings "
"(eg, 'True', 'false', 'yes', 'N', 'on', 'Off').\n"
"This warning will become an error in a future release. \r\n" "This warning will become an error in a future release. \r\n"
) )
return True return True

View File

@ -1100,7 +1100,7 @@ class ConfigTest(unittest.TestCase):
@mock.patch('compose.config.validation.log') @mock.patch('compose.config.validation.log')
def test_logs_warning_for_boolean_in_environment(self, mock_logging): def test_logs_warning_for_boolean_in_environment(self, mock_logging):
expected_warning_msg = "There is a boolean value in the 'environment' key." expected_warning_msg = "There is a boolean value in the 'environment'"
config.load( config.load(
build_config_details( build_config_details(
{'web': { {'web': {