Skip to content

Commit

Permalink
Merge pull request #4361 from shin-/4348-serialize-ext-volumes
Browse files Browse the repository at this point in the history
Remove external_name from volume def in config output
  • Loading branch information
shin- committed Jan 20, 2017
2 parents 263b9e9 + d83d318 commit 9a0962d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
7 changes: 6 additions & 1 deletion compose/config/serialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ def denormalize_config(config):
if 'external_name' in net_conf:
del net_conf['external_name']

volumes = config.volumes.copy()
for vol_name, vol_conf in volumes.items():
if 'external_name' in vol_conf:
del vol_conf['external_name']

version = config.version
if version == V1:
version = V2_1
Expand All @@ -40,7 +45,7 @@ def denormalize_config(config):
'version': version,
'services': services,
'networks': networks,
'volumes': config.volumes,
'volumes': volumes,
}


Expand Down
14 changes: 14 additions & 0 deletions tests/acceptance/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,20 @@ def test_config_external_network(self):
}
}

def test_config_external_volume(self):
self.base_dir = 'tests/fixtures/volumes'
result = self.dispatch(['-f', 'external-volumes.yml', 'config'])
json_result = yaml.load(result.stdout)
assert 'volumes' in json_result
assert json_result['volumes'] == {
'foo': {
'external': True
},
'bar': {
'external': {'name': 'some_bar'}
}
}

def test_config_v1(self):
self.base_dir = 'tests/fixtures/v1-config'
result = self.dispatch(['config'])
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/volumes/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version: '2.1'
services: {}
16 changes: 16 additions & 0 deletions tests/fixtures/volumes/external-volumes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "2.1"

services:
web:
image: busybox
command: top
volumes:
- foo:/var/lib/
- bar:/etc/

volumes:
foo:
external: true
bar:
external:
name: some_bar

0 comments on commit 9a0962d

Please sign in to comment.