Support version 3.0 of the Compose file format
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
parent
721bf89447
commit
d717c88b6e
8 changed files with 491 additions and 8 deletions
|
|
@ -285,6 +285,61 @@ class CLITestCase(DockerClientTestCase):
|
|||
'volumes': {},
|
||||
}
|
||||
|
||||
def test_config_v3(self):
|
||||
self.base_dir = 'tests/fixtures/v3-full'
|
||||
result = self.dispatch(['config'])
|
||||
|
||||
assert yaml.load(result.stdout) == {
|
||||
'version': '3.0',
|
||||
'networks': {},
|
||||
'volumes': {},
|
||||
'services': {
|
||||
'web': {
|
||||
'image': 'busybox',
|
||||
'deploy': {
|
||||
'mode': 'replicated',
|
||||
'replicas': 6,
|
||||
'labels': ['FOO=BAR'],
|
||||
'update_config': {
|
||||
'parallelism': 3,
|
||||
'delay': '10s',
|
||||
'failure_action': 'continue',
|
||||
'monitor': '60s',
|
||||
'max_failure_ratio': 0.3,
|
||||
},
|
||||
'resources': {
|
||||
'limits': {
|
||||
'cpus': '0.001',
|
||||
'memory': '50M',
|
||||
},
|
||||
'reservations': {
|
||||
'cpus': '0.0001',
|
||||
'memory': '20M',
|
||||
},
|
||||
},
|
||||
'restart_policy': {
|
||||
'condition': 'on_failure',
|
||||
'delay': '5s',
|
||||
'max_attempts': 3,
|
||||
'window': '120s',
|
||||
},
|
||||
'placement': {
|
||||
'constraints': ['node=foo'],
|
||||
},
|
||||
},
|
||||
|
||||
'healthcheck': {
|
||||
'command': 'cat /etc/passwd',
|
||||
'interval': '10s',
|
||||
'timeout': '1s',
|
||||
'retries': 5,
|
||||
},
|
||||
|
||||
'stop_grace_period': '20s',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
def test_ps(self):
|
||||
self.project.get_service('simple').create_container()
|
||||
result = self.dispatch(['ps'])
|
||||
|
|
|
|||
37
tests/fixtures/v3-full/docker-compose.yml
vendored
Normal file
37
tests/fixtures/v3-full/docker-compose.yml
vendored
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
version: "3"
|
||||
services:
|
||||
web:
|
||||
image: busybox
|
||||
|
||||
deploy:
|
||||
mode: replicated
|
||||
replicas: 6
|
||||
labels: [FOO=BAR]
|
||||
update_config:
|
||||
parallelism: 3
|
||||
delay: 10s
|
||||
failure_action: continue
|
||||
monitor: 60s
|
||||
max_failure_ratio: 0.3
|
||||
resources:
|
||||
limits:
|
||||
cpus: '0.001'
|
||||
memory: 50M
|
||||
reservations:
|
||||
cpus: '0.0001'
|
||||
memory: 20M
|
||||
restart_policy:
|
||||
condition: on_failure
|
||||
delay: 5s
|
||||
max_attempts: 3
|
||||
window: 120s
|
||||
placement:
|
||||
constraints: [node=foo]
|
||||
|
||||
healthcheck:
|
||||
command: cat /etc/passwd
|
||||
interval: 10s
|
||||
timeout: 1s
|
||||
retries: 5
|
||||
|
||||
stop_grace_period: 20s
|
||||
|
|
@ -18,6 +18,7 @@ from compose.config.config import resolve_environment
|
|||
from compose.config.config import V1
|
||||
from compose.config.config import V2_0
|
||||
from compose.config.config import V2_1
|
||||
from compose.config.config import V3_0
|
||||
from compose.config.environment import Environment
|
||||
from compose.config.errors import ConfigurationError
|
||||
from compose.config.errors import VERSION_EXPLANATION
|
||||
|
|
@ -156,9 +157,14 @@ class ConfigTest(unittest.TestCase):
|
|||
for version in ['2', '2.0']:
|
||||
cfg = config.load(build_config_details({'version': version}))
|
||||
assert cfg.version == V2_0
|
||||
|
||||
cfg = config.load(build_config_details({'version': '2.1'}))
|
||||
assert cfg.version == V2_1
|
||||
|
||||
for version in ['3', '3.0']:
|
||||
cfg = config.load(build_config_details({'version': version}))
|
||||
assert cfg.version == V3_0
|
||||
|
||||
def test_v1_file_version(self):
|
||||
cfg = config.load(build_config_details({'web': {'image': 'busybox'}}))
|
||||
assert cfg.version == V1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue