Skip to content

Commit b180b87

Browse files
committed
Remove parameters and methods marked as deprecated
Signed-off-by: Joffrey F <[email protected]>
1 parent 42b2548 commit b180b87

File tree

7 files changed

+10
-119
lines changed

7 files changed

+10
-119
lines changed

docker/api/container.py

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import six
2-
import warnings
32
from datetime import datetime
43

54
from .. import errors
@@ -204,40 +203,6 @@ def containers(self, quiet=False, all=False, trunc=False, latest=False,
204203
x['Id'] = x['Id'][:12]
205204
return res
206205

207-
@utils.check_resource('container')
208-
def copy(self, container, resource):
209-
"""
210-
Identical to the ``docker cp`` command. Get files/folders from the
211-
container.
212-
213-
**Deprecated for API version >= 1.20.** Use
214-
:py:meth:`~ContainerApiMixin.get_archive` instead.
215-
216-
Args:
217-
container (str): The container to copy from
218-
resource (str): The path within the container
219-
220-
Returns:
221-
The contents of the file as a string
222-
223-
Raises:
224-
:py:class:`docker.errors.APIError`
225-
If the server returns an error.
226-
"""
227-
if utils.version_gte(self._version, '1.20'):
228-
warnings.warn(
229-
'APIClient.copy() is deprecated for API version >= 1.20, '
230-
'please use get_archive() instead',
231-
DeprecationWarning
232-
)
233-
res = self._post_json(
234-
self._url("/containers/{0}/copy", container),
235-
data={"Resource": resource},
236-
stream=True
237-
)
238-
self._raise_for_status(res)
239-
return res.raw
240-
241206
def create_container(self, image, command=None, hostname=None, user=None,
242207
detach=False, stdin_open=False, tty=False,
243208
mem_limit=None, ports=None, environment=None,

docker/api/daemon.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import os
2-
import warnings
32
from datetime import datetime
43

54
from .. import auth, utils
6-
from ..constants import INSECURE_REGISTRY_DEPRECATION_WARNING
75

86

97
class DaemonApiMixin(object):
@@ -90,7 +88,7 @@ def info(self):
9088
return self._result(self._get(self._url("/info")), True)
9189

9290
def login(self, username, password=None, email=None, registry=None,
93-
reauth=False, insecure_registry=False, dockercfg_path=None):
91+
reauth=False, dockercfg_path=None):
9492
"""
9593
Authenticate with a registry. Similar to the ``docker login`` command.
9694
@@ -113,11 +111,6 @@ def login(self, username, password=None, email=None, registry=None,
113111
:py:class:`docker.errors.APIError`
114112
If the server returns an error.
115113
"""
116-
if insecure_registry:
117-
warnings.warn(
118-
INSECURE_REGISTRY_DEPRECATION_WARNING.format('login()'),
119-
DeprecationWarning
120-
)
121114

122115
# If we don't have any auth data so far, try reloading the config file
123116
# one more time in case anything showed up in there.

docker/api/image.py

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import logging
22
import os
3-
import warnings
43

54
import six
65

76
from .. import auth, errors, utils
8-
from ..constants import INSECURE_REGISTRY_DEPRECATION_WARNING
97

108
log = logging.getLogger(__name__)
119

@@ -321,21 +319,21 @@ def prune_images(self, filters=None):
321319
params['filters'] = utils.convert_filters(filters)
322320
return self._result(self._post(url, params=params), True)
323321

324-
def pull(self, repository, tag=None, stream=False,
325-
insecure_registry=False, auth_config=None, decode=False,
326-
platform=None):
322+
def pull(self, repository, tag=None, stream=False, auth_config=None,
323+
decode=False, platform=None):
327324
"""
328325
Pulls an image. Similar to the ``docker pull`` command.
329326
330327
Args:
331328
repository (str): The repository to pull
332329
tag (str): The tag to pull
333330
stream (bool): Stream the output as a generator
334-
insecure_registry (bool): Use an insecure registry
335331
auth_config (dict): Override the credentials that
336332
:py:meth:`~docker.api.daemon.DaemonApiMixin.login` has set for
337333
this request. ``auth_config`` should contain the ``username``
338334
and ``password`` keys to be valid.
335+
decode (bool): Decode the JSON data from the server into dicts.
336+
Only applies with ``stream=True``
339337
platform (str): Platform in the format ``os[/arch[/variant]]``
340338
341339
Returns:
@@ -361,12 +359,6 @@ def pull(self, repository, tag=None, stream=False,
361359
}
362360
363361
"""
364-
if insecure_registry:
365-
warnings.warn(
366-
INSECURE_REGISTRY_DEPRECATION_WARNING.format('pull()'),
367-
DeprecationWarning
368-
)
369-
370362
if not tag:
371363
repository, tag = utils.parse_repository_tag(repository)
372364
registry, repo_name = auth.resolve_repository_name(repository)
@@ -405,8 +397,8 @@ def pull(self, repository, tag=None, stream=False,
405397

406398
return self._result(response)
407399

408-
def push(self, repository, tag=None, stream=False,
409-
insecure_registry=False, auth_config=None, decode=False):
400+
def push(self, repository, tag=None, stream=False, auth_config=None,
401+
decode=False):
410402
"""
411403
Push an image or a repository to the registry. Similar to the ``docker
412404
push`` command.
@@ -415,12 +407,12 @@ def push(self, repository, tag=None, stream=False,
415407
repository (str): The repository to push to
416408
tag (str): An optional tag to push
417409
stream (bool): Stream the output as a blocking generator
418-
insecure_registry (bool): Use ``http://`` to connect to the
419-
registry
420410
auth_config (dict): Override the credentials that
421411
:py:meth:`~docker.api.daemon.DaemonApiMixin.login` has set for
422412
this request. ``auth_config`` should contain the ``username``
423413
and ``password`` keys to be valid.
414+
decode (bool): Decode the JSON data from the server into dicts.
415+
Only applies with ``stream=True``
424416
425417
Returns:
426418
(generator or str): The output from the server.
@@ -439,12 +431,6 @@ def push(self, repository, tag=None, stream=False,
439431
...
440432
441433
"""
442-
if insecure_registry:
443-
warnings.warn(
444-
INSECURE_REGISTRY_DEPRECATION_WARNING.format('push()'),
445-
DeprecationWarning
446-
)
447-
448434
if not tag:
449435
repository, tag = utils.parse_repository_tag(repository)
450436
registry, repo_name = auth.resolve_repository_name(repository)

docker/api/service.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import warnings
21
from .. import auth, errors, utils
32
from ..types import ServiceMode
43

@@ -123,12 +122,6 @@ def create_service(
123122
:py:class:`docker.errors.APIError`
124123
If the server returns an error.
125124
"""
126-
if endpoint_config is not None:
127-
warnings.warn(
128-
'endpoint_config has been renamed to endpoint_spec.',
129-
DeprecationWarning
130-
)
131-
endpoint_spec = endpoint_config
132125

133126
_check_api_features(
134127
self._version, task_template, update_config, endpoint_spec
@@ -370,12 +363,6 @@ def update_service(self, service, version, task_template=None, name=None,
370363
:py:class:`docker.errors.APIError`
371364
If the server returns an error.
372365
"""
373-
if endpoint_config is not None:
374-
warnings.warn(
375-
'endpoint_config has been renamed to endpoint_spec.',
376-
DeprecationWarning
377-
)
378-
endpoint_spec = endpoint_config
379366

380367
_check_api_features(
381368
self._version, task_template, update_config, endpoint_spec

docker/types/containers.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import six
2-
import warnings
32

43
from .. import errors
54
from ..utils.utils import (
@@ -542,13 +541,6 @@ def __init__(
542541
raise errors.InvalidVersion(
543542
'labels were only introduced in API version 1.18'
544543
)
545-
else:
546-
if cpuset is not None or cpu_shares is not None:
547-
warnings.warn(
548-
'The cpuset_cpus and cpu_shares options have been moved to'
549-
' host_config in API version 1.18, and will be removed',
550-
DeprecationWarning
551-
)
552544

553545
if version_lt(version, '1.19'):
554546
if volume_driver is not None:
@@ -575,13 +567,6 @@ def __init__(
575567
raise errors.InvalidVersion(
576568
'stop_signal was only introduced in API version 1.21'
577569
)
578-
else:
579-
if volume_driver is not None:
580-
warnings.warn(
581-
'The volume_driver option has been moved to'
582-
' host_config in API version 1.21, and will be removed',
583-
DeprecationWarning
584-
)
585570

586571
if stop_timeout is not None and version_lt(version, '1.25'):
587572
raise errors.InvalidVersion(

docker/utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
compare_version, convert_port_bindings, convert_volume_binds,
66
mkbuildcontext, parse_repository_tag, parse_host,
77
kwargs_from_env, convert_filters, datetime_to_timestamp,
8-
create_host_config, parse_bytes, ping_registry, parse_env_file, version_lt,
8+
create_host_config, parse_bytes, parse_env_file, version_lt,
99
version_gte, decode_json_header, split_command, create_ipam_config,
1010
create_ipam_pool, parse_devices, normalize_links, convert_service_networks,
1111
format_environment, create_archive, format_extra_hosts

docker/utils/utils.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66
import shlex
77
import tarfile
88
import tempfile
9-
import warnings
109
from distutils.version import StrictVersion
1110
from datetime import datetime
1211

13-
import requests
1412
import six
1513

1614
from .. import constants
@@ -158,29 +156,6 @@ def version_gte(v1, v2):
158156
return not version_lt(v1, v2)
159157

160158

161-
def ping_registry(url):
162-
warnings.warn(
163-
'The `ping_registry` method is deprecated and will be removed.',
164-
DeprecationWarning
165-
)
166-
167-
return ping(url + '/v2/', [401]) or ping(url + '/v1/_ping')
168-
169-
170-
def ping(url, valid_4xx_statuses=None):
171-
try:
172-
res = requests.get(url, timeout=3)
173-
except Exception:
174-
return False
175-
else:
176-
# We don't send yet auth headers
177-
# and a v2 registry will respond with status 401
178-
return (
179-
res.status_code < 400 or
180-
(valid_4xx_statuses and res.status_code in valid_4xx_statuses)
181-
)
182-
183-
184159
def _convert_port_binding(binding):
185160
result = {'HostIp': '', 'HostPort': ''}
186161
if isinstance(binding, tuple):

0 commit comments

Comments
 (0)