Kaydet (Commit) 05741a16 authored tarafından Joffrey F's avatar Joffrey F

Merge branch 'Niboo-issue1567'

......@@ -107,11 +107,14 @@ class ContainerSpec(dict):
if labels is not None:
self['Labels'] = labels
if mounts is not None:
parsed_mounts = []
for mount in mounts:
if isinstance(mount, six.string_types):
mounts.append(Mount.parse_mount_string(mount))
mounts.remove(mount)
self['Mounts'] = mounts
parsed_mounts.append(Mount.parse_mount_string(mount))
else:
# If mount already parsed
parsed_mounts.append(mount)
self['Mounts'] = parsed_mounts
if stop_grace_period is not None:
self['StopGracePeriod'] = stop_grace_period
......
......@@ -8,8 +8,8 @@ import pytest
from docker.constants import DEFAULT_DOCKER_API_VERSION
from docker.errors import InvalidArgument, InvalidVersion
from docker.types import (
ContainerConfig, EndpointConfig, HostConfig, IPAMConfig, IPAMPool,
LogConfig, Mount, ServiceMode, Ulimit,
ContainerConfig, ContainerSpec, EndpointConfig, HostConfig, IPAMConfig,
IPAMPool, LogConfig, Mount, ServiceMode, Ulimit,
)
try:
......@@ -220,6 +220,22 @@ class ContainerConfigTest(unittest.TestCase):
assert 'The volume_driver option has been moved' in str(w[0].message)
class ContainerSpecTest(unittest.TestCase):
def test_parse_mounts(self):
spec = ContainerSpec(
image='scratch', mounts=[
'/local:/container',
'/local2:/container2:ro',
Mount(target='/target', source='/source')
]
)
assert 'Mounts' in spec
assert len(spec['Mounts']) == 3
for mount in spec['Mounts']:
assert isinstance(mount, Mount)
class UlimitTest(unittest.TestCase):
def test_create_host_config_dict_ulimit(self):
ulimit_dct = {'name': 'nofile', 'soft': 8096}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment