Fix config command to print the new sections of the config
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
0f234154c2
commit
3021ee12fe
3 changed files with 30 additions and 13 deletions
|
|
@ -217,7 +217,7 @@ class TopLevelCommand(DocoptCommand):
|
||||||
|
|
||||||
compose_config = dict(
|
compose_config = dict(
|
||||||
(service.pop('name'), service) for service in compose_config.services)
|
(service.pop('name'), service) for service in compose_config.services)
|
||||||
print(yaml.dump(
|
print(yaml.safe_dump(
|
||||||
compose_config,
|
compose_config,
|
||||||
default_flow_style=False,
|
default_flow_style=False,
|
||||||
indent=2,
|
indent=2,
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ import subprocess
|
||||||
import time
|
import time
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
from operator import attrgetter
|
from operator import attrgetter
|
||||||
from textwrap import dedent
|
|
||||||
|
|
||||||
|
import yaml
|
||||||
from docker import errors
|
from docker import errors
|
||||||
|
|
||||||
from .. import mock
|
from .. import mock
|
||||||
|
|
@ -148,8 +148,9 @@ class CLITestCase(DockerClientTestCase):
|
||||||
self.base_dir = None
|
self.base_dir = None
|
||||||
|
|
||||||
def test_config_list_services(self):
|
def test_config_list_services(self):
|
||||||
|
self.base_dir = 'tests/fixtures/v2-full'
|
||||||
result = self.dispatch(['config', '--services'])
|
result = self.dispatch(['config', '--services'])
|
||||||
assert set(result.stdout.rstrip().split('\n')) == {'simple', 'another'}
|
assert set(result.stdout.rstrip().split('\n')) == {'web', 'other'}
|
||||||
|
|
||||||
def test_config_quiet_with_error(self):
|
def test_config_quiet_with_error(self):
|
||||||
self.base_dir = None
|
self.base_dir = None
|
||||||
|
|
@ -160,20 +161,32 @@ class CLITestCase(DockerClientTestCase):
|
||||||
assert "'notaservice' doesn't have any configuration" in result.stderr
|
assert "'notaservice' doesn't have any configuration" in result.stderr
|
||||||
|
|
||||||
def test_config_quiet(self):
|
def test_config_quiet(self):
|
||||||
|
self.base_dir = 'tests/fixtures/v2-full'
|
||||||
assert self.dispatch(['config', '-q']).stdout == ''
|
assert self.dispatch(['config', '-q']).stdout == ''
|
||||||
|
|
||||||
def test_config_default(self):
|
def test_config_default(self):
|
||||||
|
self.base_dir = 'tests/fixtures/v2-full'
|
||||||
result = self.dispatch(['config'])
|
result = self.dispatch(['config'])
|
||||||
assert dedent("""
|
# assert there are no python objects encoded in the output
|
||||||
simple:
|
assert '!!' not in result.stdout
|
||||||
command: top
|
|
||||||
image: busybox:latest
|
output = yaml.load(result.stdout)
|
||||||
""").lstrip() in result.stdout
|
expected = {
|
||||||
assert dedent("""
|
'version': 2,
|
||||||
another:
|
'volumes': {'data': {'driver': 'local'}},
|
||||||
command: top
|
'networks': {'front': {}},
|
||||||
image: busybox:latest
|
'services': {
|
||||||
""").lstrip() in result.stdout
|
'web': {
|
||||||
|
'build': os.path.abspath(self.base_dir),
|
||||||
|
'networks': ['front', 'default'],
|
||||||
|
},
|
||||||
|
'other': {
|
||||||
|
'image': 'busybox:latest',
|
||||||
|
'command': 'top',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
assert output == expected
|
||||||
|
|
||||||
def test_ps(self):
|
def test_ps(self):
|
||||||
self.project.get_service('simple').create_container()
|
self.project.get_service('simple').create_container()
|
||||||
|
|
|
||||||
4
tests/fixtures/v2-full/docker-compose.yml
vendored
4
tests/fixtures/v2-full/docker-compose.yml
vendored
|
|
@ -14,7 +14,11 @@ services:
|
||||||
networks:
|
networks:
|
||||||
- front
|
- front
|
||||||
- default
|
- default
|
||||||
|
volumes_from:
|
||||||
|
- other
|
||||||
|
|
||||||
other:
|
other:
|
||||||
image: busybox:latest
|
image: busybox:latest
|
||||||
command: top
|
command: top
|
||||||
|
volumes:
|
||||||
|
- /data
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue