mirror of https://github.com/docker/compose.git
Use docker SDK 2.0
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
635a281777
commit
04e5925a23
|
@ -3,7 +3,7 @@ from __future__ import unicode_literals
|
|||
|
||||
import logging
|
||||
|
||||
from docker import Client
|
||||
from docker import APIClient
|
||||
from docker.errors import TLSParameterError
|
||||
from docker.tls import TLSConfig
|
||||
from docker.utils import kwargs_from_env
|
||||
|
@ -71,4 +71,4 @@ def docker_client(environment, version=None, tls_config=None, host=None,
|
|||
|
||||
kwargs['user_agent'] = generate_user_agent()
|
||||
|
||||
return Client(**kwargs)
|
||||
return APIClient(**kwargs)
|
||||
|
|
|
@ -4,8 +4,8 @@ from __future__ import unicode_literals
|
|||
import logging
|
||||
|
||||
from docker.errors import NotFound
|
||||
from docker.utils import create_ipam_config
|
||||
from docker.utils import create_ipam_pool
|
||||
from docker.types import IPAMConfig
|
||||
from docker.types import IPAMPool
|
||||
|
||||
from .config import ConfigurationError
|
||||
|
||||
|
@ -96,10 +96,10 @@ def create_ipam_config_from_dict(ipam_dict):
|
|||
if not ipam_dict:
|
||||
return None
|
||||
|
||||
return create_ipam_config(
|
||||
return IPAMConfig(
|
||||
driver=ipam_dict.get('driver'),
|
||||
pool_configs=[
|
||||
create_ipam_pool(
|
||||
IPAMPool(
|
||||
subnet=config.get('subnet'),
|
||||
iprange=config.get('ip_range'),
|
||||
gateway=config.get('gateway'),
|
||||
|
|
|
@ -11,7 +11,7 @@ import enum
|
|||
import six
|
||||
from docker.errors import APIError
|
||||
from docker.errors import NotFound
|
||||
from docker.utils import LogConfig
|
||||
from docker.types import LogConfig
|
||||
from docker.utils.ports import build_port_bindings
|
||||
from docker.utils.ports import split_port
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
PyYAML==3.11
|
||||
backports.ssl-match-hostname==3.5.0.1; python_version < '3'
|
||||
cached-property==1.2.0
|
||||
docker==2.0.0
|
||||
dockerpty==0.4.1
|
||||
docopt==0.6.1
|
||||
enum34==1.0.4; python_version < '3.4'
|
||||
functools32==3.2.3.post2; python_version < '3.2'
|
||||
git+https://github.com/docker/docker-py.git@2ff7371ae7703033f981e1b137a3be0caf7a4f9c#egg=docker-py
|
||||
ipaddress==1.0.16
|
||||
jsonschema==2.5.1
|
||||
pypiwin32==219; sys_platform == 'win32'
|
||||
|
|
2
setup.py
2
setup.py
|
@ -34,7 +34,7 @@ install_requires = [
|
|||
'requests >= 2.6.1, != 2.11.0, < 2.12',
|
||||
'texttable >= 0.8.1, < 0.9',
|
||||
'websocket-client >= 0.32.0, < 1.0',
|
||||
'docker-py >= 1.10.6, < 2.0',
|
||||
'docker >= 2.0.0, < 3.0',
|
||||
'dockerpty >= 0.4.1, < 0.5',
|
||||
'six >= 1.3.0, < 2',
|
||||
'jsonschema >= 2.5.1, < 3',
|
||||
|
|
|
@ -15,7 +15,7 @@ from compose.config.config import Config
|
|||
def mock_service():
|
||||
return mock.create_autospec(
|
||||
service.Service,
|
||||
client=mock.create_autospec(docker.Client),
|
||||
client=mock.create_autospec(docker.APIClient),
|
||||
options={})
|
||||
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ class CLITestCase(unittest.TestCase):
|
|||
@mock.patch('compose.cli.main.RunOperation', autospec=True)
|
||||
@mock.patch('compose.cli.main.PseudoTerminal', autospec=True)
|
||||
def test_run_interactive_passes_logs_false(self, mock_pseudo_terminal, mock_run_operation):
|
||||
mock_client = mock.create_autospec(docker.Client)
|
||||
mock_client = mock.create_autospec(docker.APIClient)
|
||||
project = Project.from_config(
|
||||
name='composetest',
|
||||
client=mock_client,
|
||||
|
@ -128,7 +128,7 @@ class CLITestCase(unittest.TestCase):
|
|||
assert call_kwargs['logs'] is False
|
||||
|
||||
def test_run_service_with_restart_always(self):
|
||||
mock_client = mock.create_autospec(docker.Client)
|
||||
mock_client = mock.create_autospec(docker.APIClient)
|
||||
|
||||
project = Project.from_config(
|
||||
name='composetest',
|
||||
|
|
|
@ -98,7 +98,7 @@ class ContainerTest(unittest.TestCase):
|
|||
self.assertEqual(container.name_without_project, "custom_name_of_container")
|
||||
|
||||
def test_inspect_if_not_inspected(self):
|
||||
mock_client = mock.create_autospec(docker.Client)
|
||||
mock_client = mock.create_autospec(docker.APIClient)
|
||||
container = Container(mock_client, dict(Id="the_id"))
|
||||
|
||||
container.inspect_if_not_inspected()
|
||||
|
|
|
@ -19,7 +19,7 @@ from compose.service import Service
|
|||
|
||||
class ProjectTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.mock_client = mock.create_autospec(docker.Client)
|
||||
self.mock_client = mock.create_autospec(docker.APIClient)
|
||||
|
||||
def test_from_config(self):
|
||||
config = Config(
|
||||
|
|
|
@ -34,7 +34,7 @@ from compose.service import warn_on_masked_volume
|
|||
class ServiceTest(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.mock_client = mock.create_autospec(docker.Client)
|
||||
self.mock_client = mock.create_autospec(docker.APIClient)
|
||||
|
||||
def test_containers(self):
|
||||
service = Service('db', self.mock_client, 'myproject', image='foo')
|
||||
|
@ -666,7 +666,7 @@ class ServiceTest(unittest.TestCase):
|
|||
class TestServiceNetwork(object):
|
||||
|
||||
def test_connect_container_to_networks_short_aliase_exists(self):
|
||||
mock_client = mock.create_autospec(docker.Client)
|
||||
mock_client = mock.create_autospec(docker.APIClient)
|
||||
service = Service(
|
||||
'db',
|
||||
mock_client,
|
||||
|
@ -751,7 +751,7 @@ class NetTestCase(unittest.TestCase):
|
|||
def test_network_mode_service(self):
|
||||
container_id = 'bbbb'
|
||||
service_name = 'web'
|
||||
mock_client = mock.create_autospec(docker.Client)
|
||||
mock_client = mock.create_autospec(docker.APIClient)
|
||||
mock_client.containers.return_value = [
|
||||
{'Id': container_id, 'Name': container_id, 'Image': 'abcd'},
|
||||
]
|
||||
|
@ -765,7 +765,7 @@ class NetTestCase(unittest.TestCase):
|
|||
|
||||
def test_network_mode_service_no_containers(self):
|
||||
service_name = 'web'
|
||||
mock_client = mock.create_autospec(docker.Client)
|
||||
mock_client = mock.create_autospec(docker.APIClient)
|
||||
mock_client.containers.return_value = []
|
||||
|
||||
service = Service(name=service_name, client=mock_client)
|
||||
|
@ -783,7 +783,7 @@ def build_mount(destination, source, mode='rw'):
|
|||
class ServiceVolumesTest(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.mock_client = mock.create_autospec(docker.Client)
|
||||
self.mock_client = mock.create_autospec(docker.APIClient)
|
||||
|
||||
def test_build_volume_binding(self):
|
||||
binding = build_volume_binding(VolumeSpec.parse('/outside:/inside', True))
|
||||
|
|
|
@ -10,7 +10,7 @@ from tests import mock
|
|||
|
||||
@pytest.fixture
|
||||
def mock_client():
|
||||
return mock.create_autospec(docker.Client)
|
||||
return mock.create_autospec(docker.APIClient)
|
||||
|
||||
|
||||
class TestVolume(object):
|
||||
|
|
Loading…
Reference in New Issue