image/appc: fix volume conversion and add tests
This commit is contained in:
parent
048f932094
commit
7a957c94c8
3 changed files with 24 additions and 3 deletions
|
@ -156,8 +156,8 @@ class DockerV1ToACIManifestTranslator(object):
|
|||
volume_name = DockerV1ToACIManifestTranslator._ac_name(docker_volume_path)
|
||||
return "volume-%s" % volume_name
|
||||
|
||||
volume_list = docker_config['Volumes'] or docker_config['volumes'] or []
|
||||
for docker_volume_path in volume_list:
|
||||
volume_list = docker_config['Volumes'] or docker_config['volumes'] or {}
|
||||
for docker_volume_path in volume_list.iterkeys():
|
||||
if not docker_volume_path:
|
||||
continue
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ import pytest
|
|||
|
||||
from image.appc import DockerV1ToACIManifestTranslator
|
||||
from data.interfaces.verbs import RepositoryReference, ImageWithBlob
|
||||
from util.dict_wrappers import JSONPathDict
|
||||
|
||||
|
||||
EXAMPLE_MANIFEST_OBJ = {
|
||||
|
@ -96,3 +97,16 @@ def test_legacy_port_conversion(repo_image):
|
|||
ports.sort()
|
||||
assert {'name':'port-8080', 'port':8080, 'protocol':'tcp'} == ports[0]
|
||||
assert {'name':'port-8081', 'port':8081, 'protocol':'tcp'} == ports[1]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("vcfg,expected", [
|
||||
({'Volumes': None}, []),
|
||||
({'Volumes': {}}, []),
|
||||
({'Volumes': {'/bin': {}}}, [{'name': 'volume-bin', 'path': '/bin', 'readOnly': False}]),
|
||||
({'volumes': None}, []),
|
||||
({'volumes': {}}, []),
|
||||
({'volumes': {'/bin': {}}}, [{'name': 'volume-bin', 'path': '/bin', 'readOnly': False}]),
|
||||
])
|
||||
def test_volume_version_easy(vcfg, expected):
|
||||
output = DockerV1ToACIManifestTranslator._build_volumes(JSONPathDict(vcfg))
|
||||
assert output == expected
|
||||
|
|
Reference in a new issue