mirror of https://github.com/docker/docker-py.git
Merge pull request #198 from fcoelho/fix-volumes-from
Sanitize create_container input for volumes_from
This commit is contained in:
commit
6c1f7f3e97
|
@ -121,8 +121,12 @@ class Client(requests.Session):
|
|||
volumes_dict[vol] = {}
|
||||
volumes = volumes_dict
|
||||
|
||||
if volumes_from and not isinstance(volumes_from, six.string_types):
|
||||
volumes_from = ','.join(volumes_from)
|
||||
if volumes_from:
|
||||
if not isinstance(volumes_from, six.string_types):
|
||||
volumes_from = ','.join(volumes_from)
|
||||
else:
|
||||
# Force None, an empty list or dict causes client.start to fail
|
||||
volumes_from = None
|
||||
|
||||
attach_stdin = False
|
||||
attach_stdout = False
|
||||
|
|
|
@ -342,6 +342,16 @@ class DockerClientTest(unittest.TestCase):
|
|||
self.assertEqual(args[1]['headers'],
|
||||
{'Content-Type': 'application/json'})
|
||||
|
||||
def test_create_container_empty_volumes_from(self):
|
||||
try:
|
||||
self.client.create_container('busybox', 'true', volumes_from=[])
|
||||
except Exception as e:
|
||||
self.fail('Command should not raise exception: {0}'.format(e))
|
||||
|
||||
args = fake_request.call_args
|
||||
data = json.loads(args[1]['data'])
|
||||
self.assertTrue('VolumesFrom' not in data)
|
||||
|
||||
def test_create_named_container(self):
|
||||
try:
|
||||
self.client.create_container('busybox', 'true',
|
||||
|
|
Loading…
Reference in New Issue