mirror of https://github.com/docker/compose.git
Use json to encode invalid values in configuration errors so that the user sees a proper repr of the value.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
475a091768
commit
bf1552da79
|
@ -1,3 +1,6 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from compose.cli.main import main
|
from compose.cli.main import main
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from compose.config.errors import DependencyError
|
from compose.config.errors import DependencyError
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -254,7 +254,8 @@ def _parse_oneof_validator(error):
|
||||||
)
|
)
|
||||||
return "{}contains {}, which is an invalid type, it should be {}".format(
|
return "{}contains {}, which is an invalid type, it should be {}".format(
|
||||||
invalid_config_key,
|
invalid_config_key,
|
||||||
context.instance,
|
# Always print the json repr of the invalid value
|
||||||
|
json.dumps(context.instance),
|
||||||
_parse_valid_types_from_validator(context.validator_value))
|
_parse_valid_types_from_validator(context.validator_value))
|
||||||
|
|
||||||
if context.validator == 'uniqueItems':
|
if context.validator == 'uniqueItems':
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
from __future__ import print_function
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from docker.errors import DockerException
|
from docker.errors import DockerException
|
||||||
|
|
|
@ -552,7 +552,9 @@ class ConfigTest(unittest.TestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_config_extra_hosts_list_of_dicts_validation_error(self):
|
def test_config_extra_hosts_list_of_dicts_validation_error(self):
|
||||||
expected_error_msg = "key 'extra_hosts' contains {'somehost': '162.242.195.82'}, which is an invalid type, it should be a string"
|
expected_error_msg = (
|
||||||
|
"key 'extra_hosts' contains {\"somehost\": \"162.242.195.82\"}, "
|
||||||
|
"which is an invalid type, it should be a string")
|
||||||
|
|
||||||
with self.assertRaisesRegexp(ConfigurationError, expected_error_msg):
|
with self.assertRaisesRegexp(ConfigurationError, expected_error_msg):
|
||||||
config.load(
|
config.load(
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from compose.config.errors import ConfigurationError
|
from compose.config.errors import ConfigurationError
|
||||||
|
|
Loading…
Reference in New Issue