diff options
author | Joffrey F <joffrey@docker.com> | 2018-01-31 13:14:21 -0800 |
---|---|---|
committer | Joffrey F <joffrey@docker.com> | 2018-01-31 13:14:21 -0800 |
commit | b180b8770a265e33099bd6da76c3e556a1028491 (patch) | |
tree | ed7d95c101cba7744333785c9f0b910edeb79d64 | |
parent | 42b2548e5d51ed2b92e31e288d1f902f4a6dd445 (diff) | |
download | docker-py-b180b8770a265e33099bd6da76c3e556a1028491.tar.gz |
Remove parameters and methods marked as deprecated
Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r-- | docker/api/container.py | 35 | ||||
-rw-r--r-- | docker/api/daemon.py | 9 | ||||
-rw-r--r-- | docker/api/image.py | 30 | ||||
-rw-r--r-- | docker/api/service.py | 13 | ||||
-rw-r--r-- | docker/types/containers.py | 15 | ||||
-rw-r--r-- | docker/utils/__init__.py | 2 | ||||
-rw-r--r-- | docker/utils/utils.py | 25 |
7 files changed, 10 insertions, 119 deletions
diff --git a/docker/api/container.py b/docker/api/container.py index 260fbe9..419ae44 100644 --- a/docker/api/container.py +++ b/docker/api/container.py @@ -1,5 +1,4 @@ import six -import warnings from datetime import datetime from .. import errors @@ -204,40 +203,6 @@ class ContainerApiMixin(object): x['Id'] = x['Id'][:12] return res - @utils.check_resource('container') - def copy(self, container, resource): - """ - Identical to the ``docker cp`` command. Get files/folders from the - container. - - **Deprecated for API version >= 1.20.** Use - :py:meth:`~ContainerApiMixin.get_archive` instead. - - Args: - container (str): The container to copy from - resource (str): The path within the container - - Returns: - The contents of the file as a string - - Raises: - :py:class:`docker.errors.APIError` - If the server returns an error. - """ - if utils.version_gte(self._version, '1.20'): - warnings.warn( - 'APIClient.copy() is deprecated for API version >= 1.20, ' - 'please use get_archive() instead', - DeprecationWarning - ) - res = self._post_json( - self._url("/containers/{0}/copy", container), - data={"Resource": resource}, - stream=True - ) - self._raise_for_status(res) - return res.raw - def create_container(self, image, command=None, hostname=None, user=None, detach=False, stdin_open=False, tty=False, mem_limit=None, ports=None, environment=None, diff --git a/docker/api/daemon.py b/docker/api/daemon.py index 3998967..033dbf1 100644 --- a/docker/api/daemon.py +++ b/docker/api/daemon.py @@ -1,9 +1,7 @@ import os -import warnings from datetime import datetime from .. import auth, utils -from ..constants import INSECURE_REGISTRY_DEPRECATION_WARNING class DaemonApiMixin(object): @@ -90,7 +88,7 @@ class DaemonApiMixin(object): return self._result(self._get(self._url("/info")), True) def login(self, username, password=None, email=None, registry=None, - reauth=False, insecure_registry=False, dockercfg_path=None): + reauth=False, dockercfg_path=None): """ Authenticate with a registry. Similar to the ``docker login`` command. @@ -113,11 +111,6 @@ class DaemonApiMixin(object): :py:class:`docker.errors.APIError` If the server returns an error. """ - if insecure_registry: - warnings.warn( - INSECURE_REGISTRY_DEPRECATION_WARNING.format('login()'), - DeprecationWarning - ) # If we don't have any auth data so far, try reloading the config file # one more time in case anything showed up in there. diff --git a/docker/api/image.py b/docker/api/image.py index b3dcd3a..f37d2dd 100644 --- a/docker/api/image.py +++ b/docker/api/image.py @@ -1,11 +1,9 @@ import logging import os -import warnings import six from .. import auth, errors, utils -from ..constants import INSECURE_REGISTRY_DEPRECATION_WARNING log = logging.getLogger(__name__) @@ -321,9 +319,8 @@ class ImageApiMixin(object): params['filters'] = utils.convert_filters(filters) return self._result(self._post(url, params=params), True) - def pull(self, repository, tag=None, stream=False, - insecure_registry=False, auth_config=None, decode=False, - platform=None): + def pull(self, repository, tag=None, stream=False, auth_config=None, + decode=False, platform=None): """ Pulls an image. Similar to the ``docker pull`` command. @@ -331,11 +328,12 @@ class ImageApiMixin(object): repository (str): The repository to pull tag (str): The tag to pull stream (bool): Stream the output as a generator - insecure_registry (bool): Use an insecure registry auth_config (dict): Override the credentials that :py:meth:`~docker.api.daemon.DaemonApiMixin.login` has set for this request. ``auth_config`` should contain the ``username`` and ``password`` keys to be valid. + decode (bool): Decode the JSON data from the server into dicts. + Only applies with ``stream=True`` platform (str): Platform in the format ``os[/arch[/variant]]`` Returns: @@ -361,12 +359,6 @@ class ImageApiMixin(object): } """ - if insecure_registry: - warnings.warn( - INSECURE_REGISTRY_DEPRECATION_WARNING.format('pull()'), - DeprecationWarning - ) - if not tag: repository, tag = utils.parse_repository_tag(repository) registry, repo_name = auth.resolve_repository_name(repository) @@ -405,8 +397,8 @@ class ImageApiMixin(object): return self._result(response) - def push(self, repository, tag=None, stream=False, - insecure_registry=False, auth_config=None, decode=False): + def push(self, repository, tag=None, stream=False, auth_config=None, + decode=False): """ Push an image or a repository to the registry. Similar to the ``docker push`` command. @@ -415,12 +407,12 @@ class ImageApiMixin(object): repository (str): The repository to push to tag (str): An optional tag to push stream (bool): Stream the output as a blocking generator - insecure_registry (bool): Use ``http://`` to connect to the - registry auth_config (dict): Override the credentials that :py:meth:`~docker.api.daemon.DaemonApiMixin.login` has set for this request. ``auth_config`` should contain the ``username`` and ``password`` keys to be valid. + decode (bool): Decode the JSON data from the server into dicts. + Only applies with ``stream=True`` Returns: (generator or str): The output from the server. @@ -439,12 +431,6 @@ class ImageApiMixin(object): ... """ - if insecure_registry: - warnings.warn( - INSECURE_REGISTRY_DEPRECATION_WARNING.format('push()'), - DeprecationWarning - ) - if not tag: repository, tag = utils.parse_repository_tag(repository) registry, repo_name = auth.resolve_repository_name(repository) diff --git a/docker/api/service.py b/docker/api/service.py index 051d34f..ceae8fc 100644 --- a/docker/api/service.py +++ b/docker/api/service.py @@ -1,4 +1,3 @@ -import warnings from .. import auth, errors, utils from ..types import ServiceMode @@ -123,12 +122,6 @@ class ServiceApiMixin(object): :py:class:`docker.errors.APIError` If the server returns an error. """ - if endpoint_config is not None: - warnings.warn( - 'endpoint_config has been renamed to endpoint_spec.', - DeprecationWarning - ) - endpoint_spec = endpoint_config _check_api_features( self._version, task_template, update_config, endpoint_spec @@ -370,12 +363,6 @@ class ServiceApiMixin(object): :py:class:`docker.errors.APIError` If the server returns an error. """ - if endpoint_config is not None: - warnings.warn( - 'endpoint_config has been renamed to endpoint_spec.', - DeprecationWarning - ) - endpoint_spec = endpoint_config _check_api_features( self._version, task_template, update_config, endpoint_spec diff --git a/docker/types/containers.py b/docker/types/containers.py index 15dd86c..3f15905 100644 --- a/docker/types/containers.py +++ b/docker/types/containers.py @@ -1,5 +1,4 @@ import six -import warnings from .. import errors from ..utils.utils import ( @@ -542,13 +541,6 @@ class ContainerConfig(dict): raise errors.InvalidVersion( 'labels were only introduced in API version 1.18' ) - else: - if cpuset is not None or cpu_shares is not None: - warnings.warn( - 'The cpuset_cpus and cpu_shares options have been moved to' - ' host_config in API version 1.18, and will be removed', - DeprecationWarning - ) if version_lt(version, '1.19'): if volume_driver is not None: @@ -575,13 +567,6 @@ class ContainerConfig(dict): raise errors.InvalidVersion( 'stop_signal was only introduced in API version 1.21' ) - else: - if volume_driver is not None: - warnings.warn( - 'The volume_driver option has been moved to' - ' host_config in API version 1.21, and will be removed', - DeprecationWarning - ) if stop_timeout is not None and version_lt(version, '1.25'): raise errors.InvalidVersion( diff --git a/docker/utils/__init__.py b/docker/utils/__init__.py index c162e3b..e70a5e6 100644 --- a/docker/utils/__init__.py +++ b/docker/utils/__init__.py @@ -5,7 +5,7 @@ from .utils import ( compare_version, convert_port_bindings, convert_volume_binds, mkbuildcontext, parse_repository_tag, parse_host, kwargs_from_env, convert_filters, datetime_to_timestamp, - create_host_config, parse_bytes, ping_registry, parse_env_file, version_lt, + create_host_config, parse_bytes, parse_env_file, version_lt, version_gte, decode_json_header, split_command, create_ipam_config, create_ipam_pool, parse_devices, normalize_links, convert_service_networks, format_environment, create_archive, format_extra_hosts diff --git a/docker/utils/utils.py b/docker/utils/utils.py index c4db175..e4e2c0d 100644 --- a/docker/utils/utils.py +++ b/docker/utils/utils.py @@ -6,11 +6,9 @@ import json import shlex import tarfile import tempfile -import warnings from distutils.version import StrictVersion from datetime import datetime -import requests import six from .. import constants @@ -158,29 +156,6 @@ def version_gte(v1, v2): return not version_lt(v1, v2) -def ping_registry(url): - warnings.warn( - 'The `ping_registry` method is deprecated and will be removed.', - DeprecationWarning - ) - - return ping(url + '/v2/', [401]) or ping(url + '/v1/_ping') - - -def ping(url, valid_4xx_statuses=None): - try: - res = requests.get(url, timeout=3) - except Exception: - return False - else: - # We don't send yet auth headers - # and a v2 registry will respond with status 401 - return ( - res.status_code < 400 or - (valid_4xx_statuses and res.status_code in valid_4xx_statuses) - ) - - def _convert_port_binding(binding): result = {'HostIp': '', 'HostPort': ''} if isinstance(binding, tuple): |