Skip to content

Commit

Permalink
Fix version 3.1
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Nephin <dnephin@docker.com>
  • Loading branch information
dnephin authored and shin- committed Feb 9, 2017
1 parent 4e2e383 commit c79a1c7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
11 changes: 4 additions & 7 deletions compose/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,6 @@ def version(self):
if version == '3':
version = V3_0

if version not in (V2_0, V2_1, V3_0):
raise ConfigurationError(
'Version in "{}" is unsupported. {}'
.format(self.filename, VERSION_EXPLANATION))

return version

def get_service(self, name):
Expand Down Expand Up @@ -479,7 +474,7 @@ def process_config_file(config_file, environment, service_name=None):
'service',
environment)

if config_file.version in (V2_0, V2_1, V3_0):
if config_file.version in (V2_0, V2_1, V3_0, V3_1):
processed_config = dict(config_file.config)
processed_config['services'] = services
processed_config['volumes'] = interpolate_config_section(
Expand All @@ -495,7 +490,9 @@ def process_config_file(config_file, environment, service_name=None):
elif config_file.version == V1:
processed_config = services
else:
raise Exception("Unsupported version: {}".format(repr(config_file.version)))
raise ConfigurationError(
'Version in "{}" is unsupported. {}'
.format(config_file.filename, VERSION_EXPLANATION))

config_file = config_file._replace(config=processed_config)
validate_against_config_schema(config_file)
Expand Down
5 changes: 5 additions & 0 deletions docker-compose.spec
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ exe = EXE(pyz,
'compose/config/config_schema_v3.0.json',
'DATA'
),
(
'compose/config/config_schema_v3.1.json',
'compose/config/config_schema_v3.1.json',
'DATA'
),
(
'compose/GITSHA',
'compose/GITSHA',
Expand Down
4 changes: 4 additions & 0 deletions tests/unit/config/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from compose.config.config import V2_0
from compose.config.config import V2_1
from compose.config.config import V3_0
from compose.config.config import V3_1
from compose.config.environment import Environment
from compose.config.errors import ConfigurationError
from compose.config.errors import VERSION_EXPLANATION
Expand Down Expand Up @@ -168,6 +169,9 @@ def test_valid_versions(self):
cfg = config.load(build_config_details({'version': version}))
assert cfg.version == V3_0

cfg = config.load(build_config_details({'version': '3.1'}))
assert cfg.version == V3_1

def test_v1_file_version(self):
cfg = config.load(build_config_details({'web': {'image': 'busybox'}}))
assert cfg.version == V1
Expand Down

0 comments on commit c79a1c7

Please sign in to comment.