mirror of https://github.com/docker/compose.git
Do not allow to specify both image and dockerfile in configuration. Closes #1908
Signed-off-by: Karol Duleba <mr.fuxi@gmail.com>
This commit is contained in:
parent
ecd1cc31dc
commit
477d4f491d
|
@ -113,7 +113,10 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"required": ["image"],
|
"required": ["image"],
|
||||||
"not": {"required": ["build"]}
|
"not": {"anyOf": [
|
||||||
|
{"required": ["build"]},
|
||||||
|
{"required": ["dockerfile"]}
|
||||||
|
]}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"required": ["extends"],
|
"required": ["extends"],
|
||||||
|
|
|
@ -134,6 +134,11 @@ def process_errors(errors):
|
||||||
required.append(
|
required.append(
|
||||||
"Service '{}' has neither an image nor a build path "
|
"Service '{}' has neither an image nor a build path "
|
||||||
"specified. Exactly one must be provided.".format(service_name))
|
"specified. Exactly one must be provided.".format(service_name))
|
||||||
|
elif 'image' in error.instance and 'dockerfile' in error.instance:
|
||||||
|
required.append(
|
||||||
|
"Service '{}' has both an image and alternate Dockerfile. "
|
||||||
|
"A service can either be built to image or use an existing "
|
||||||
|
"image, not both.".format(service_name))
|
||||||
else:
|
else:
|
||||||
required.append(_clean_error_message(error.message))
|
required.append(_clean_error_message(error.message))
|
||||||
elif error.validator == 'oneOf':
|
elif error.validator == 'oneOf':
|
||||||
|
|
|
@ -33,6 +33,8 @@ pull if it doesn't exist locally.
|
||||||
image: a4bc65fd
|
image: a4bc65fd
|
||||||
image: busybox@sha256:38a203e1986cf79639cfb9b2e1d6e773de84002feea2d4eb006b52004ee8502d
|
image: busybox@sha256:38a203e1986cf79639cfb9b2e1d6e773de84002feea2d4eb006b52004ee8502d
|
||||||
|
|
||||||
|
Using `image` together with either `build` or `dockerfile` is not allowed. Attempting to do so results in an error.
|
||||||
|
|
||||||
### build
|
### build
|
||||||
|
|
||||||
Path to a directory containing a Dockerfile. When the value supplied is a
|
Path to a directory containing a Dockerfile. When the value supplied is a
|
||||||
|
@ -43,6 +45,8 @@ Compose will build and tag it with a generated name, and use that image thereaft
|
||||||
|
|
||||||
build: /path/to/build/dir
|
build: /path/to/build/dir
|
||||||
|
|
||||||
|
Using `build` together with `image` is not allowed. Attempting to do so results in an error.
|
||||||
|
|
||||||
### dockerfile
|
### dockerfile
|
||||||
|
|
||||||
Alternate Dockerfile.
|
Alternate Dockerfile.
|
||||||
|
@ -51,6 +55,8 @@ Compose will use an alternate file to build with.
|
||||||
|
|
||||||
dockerfile: Dockerfile-alternate
|
dockerfile: Dockerfile-alternate
|
||||||
|
|
||||||
|
Using `dockerfile` together with `image` is not allowed. Attempting to do so results in an error.
|
||||||
|
|
||||||
### command
|
### command
|
||||||
|
|
||||||
Override the default command.
|
Override the default command.
|
||||||
|
|
|
@ -191,6 +191,17 @@ class ConfigTest(unittest.TestCase):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_config_image_and_dockerfile_raise_validation_error(self):
|
||||||
|
expected_error_msg = "Service 'web' has both an image and alternate Dockerfile."
|
||||||
|
with self.assertRaisesRegexp(ConfigurationError, expected_error_msg):
|
||||||
|
config.load(
|
||||||
|
config.ConfigDetails(
|
||||||
|
{'web': {'image': 'busybox', 'dockerfile': 'Dockerfile.alt'}},
|
||||||
|
'working_dir',
|
||||||
|
'filename.yml'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class InterpolationTest(unittest.TestCase):
|
class InterpolationTest(unittest.TestCase):
|
||||||
@mock.patch.dict(os.environ)
|
@mock.patch.dict(os.environ)
|
||||||
|
|
Loading…
Reference in New Issue