Skip to content

Commit

Permalink
Merge pull request #2331 from docker/4.0.0-release
Browse files Browse the repository at this point in the history
4.0.0 release
  • Loading branch information
shin- authored May 19, 2019
2 parents a4c251d + 5de5af1 commit 5d42ab8
Show file tree
Hide file tree
Showing 51 changed files with 918 additions and 249 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ matrix:
include:
- python: 2.7
env: TOXENV=py27
- python: 3.4
env: TOXENV=py34
- python: 3.5
env: TOXENV=py35
- python: 3.6
Expand Down
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def buildImages = { ->
imageNamePy2 = "${imageNameBase}:py2-${gitCommit()}"
imageNamePy3 = "${imageNameBase}:py3-${gitCommit()}"

buildImage(imageNamePy2, ".", "py2.7")
buildImage(imageNamePy3, "-f Dockerfile-py3 .", "py3.6")
buildImage(imageNamePy2, "-f tests/Dockerfile --build-arg PYTHON_VERSION=2.7 .", "py2.7")
buildImage(imageNamePy3, "-f tests/Dockerfile --build-arg PYTHON_VERSION=3.6 .", "py3.6")
}
}
}
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ include LICENSE
recursive-include tests *.py
recursive-include tests/unit/testdata *
recursive-include tests/integration/testdata *
recursive-include tests/gpg-keys *
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ clean:

.PHONY: build
build:
docker build -t docker-sdk-python .
docker build -t docker-sdk-python -f tests/Dockerfile --build-arg PYTHON_VERSION=2.7 .

.PHONY: build-py3
build-py3:
docker build -t docker-sdk-python3 -f Dockerfile-py3 .
docker build -t docker-sdk-python3 -f tests/Dockerfile .

.PHONY: build-docs
build-docs:
Expand All @@ -39,10 +39,10 @@ integration-test: build

.PHONY: integration-test-py3
integration-test-py3: build-py3
docker run -t --rm -v /var/run/docker.sock:/var/run/docker.sock docker-sdk-python3 py.test tests/integration/${file}
docker run -t --rm -v /var/run/docker.sock:/var/run/docker.sock docker-sdk-python3 py.test -v tests/integration/${file}

TEST_API_VERSION ?= 1.35
TEST_ENGINE_VERSION ?= 17.12.0-ce
TEST_ENGINE_VERSION ?= 18.09.5

.PHONY: setup-network
setup-network:
Expand Down
3 changes: 2 additions & 1 deletion docker/api/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
decode=False, buildargs=None, gzip=False, shmsize=None,
labels=None, cache_from=None, target=None, network_mode=None,
squash=None, extra_hosts=None, platform=None, isolation=None,
use_config_proxy=False):
use_config_proxy=True):
"""
Similar to the ``docker build`` command. Either ``path`` or ``fileobj``
needs to be set. ``path`` can be a local path (to a directory
Expand Down Expand Up @@ -121,6 +121,7 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
remote = context = None
headers = {}
container_limits = container_limits or {}
buildargs = buildargs or {}
if path is None and fileobj is None:
raise TypeError("Either path or fileobj needs to be provided.")
if gzip and encoding is not None:
Expand Down
2 changes: 1 addition & 1 deletion docker/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class APIClient(
base_url (str): URL to the Docker server. For example,
``unix:///var/run/docker.sock`` or ``tcp://127.0.0.1:1234``.
version (str): The version of the API to use. Set to ``auto`` to
automatically detect the server's version. Default: ``1.30``
automatically detect the server's version. Default: ``1.35``
timeout (int): Default timeout for API calls, in seconds.
tls (bool or :py:class:`~docker.tls.TLSConfig`): Enable TLS. Pass
``True`` to enable it with default options, or pass a
Expand Down
26 changes: 14 additions & 12 deletions docker/api/container.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import six
from datetime import datetime

import six

from .. import errors
from .. import utils
from ..constants import DEFAULT_DATA_CHUNK_SIZE
from ..types import (
CancellableStream, ContainerConfig, EndpointConfig, HostConfig,
NetworkingConfig
)
from ..types import CancellableStream
from ..types import ContainerConfig
from ..types import EndpointConfig
from ..types import HostConfig
from ..types import NetworkingConfig


class ContainerApiMixin(object):
Expand Down Expand Up @@ -222,7 +224,7 @@ def create_container(self, image, command=None, hostname=None, user=None,
mac_address=None, labels=None, stop_signal=None,
networking_config=None, healthcheck=None,
stop_timeout=None, runtime=None,
use_config_proxy=False):
use_config_proxy=True):
"""
Creates a container. Parameters are similar to those for the ``docker
run`` command except it doesn't support the attach options (``-a``).
Expand Down Expand Up @@ -414,7 +416,7 @@ def create_container(self, image, command=None, hostname=None, user=None,
if use_config_proxy:
environment = self._proxy_configs.inject_proxy_environment(
environment
)
) or None

config = self.create_container_config(
image, command, hostname, user, detach, stdin_open, tty,
Expand Down Expand Up @@ -487,7 +489,6 @@ def create_host_config(self, *args, **kwargs):
IDs that the container process will run as.
init (bool): Run an init inside the container that forwards
signals and reaps processes
init_path (str): Path to the docker-init binary
ipc_mode (str): Set the IPC mode for the container.
isolation (str): Isolation technology to use. Default: ``None``.
links (dict): Mapping of links using the
Expand All @@ -512,7 +513,7 @@ def create_host_config(self, *args, **kwargs):
network_mode (str): One of:
- ``bridge`` Create a new network stack for the container on
on the bridge network.
the bridge network.
- ``none`` No networking for this container.
- ``container:<name|id>`` Reuse another container's network
stack.
Expand Down Expand Up @@ -915,9 +916,10 @@ def port(self, container, private_port):
if '/' in private_port:
return port_settings.get(private_port)

h_ports = port_settings.get(private_port + '/tcp')
if h_ports is None:
h_ports = port_settings.get(private_port + '/udp')
for protocol in ['tcp', 'udp', 'sctp']:
h_ports = port_settings.get(private_port + '/' + protocol)
if h_ports:
break

return h_ports

Expand Down
3 changes: 2 additions & 1 deletion docker/api/exec_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ def exec_start(self, exec_id, detach=False, tty=False, stream=False,
(generator or str or tuple): If ``stream=True``, a generator
yielding response chunks. If ``socket=True``, a socket object for
the connection. A string containing response data otherwise. If
``demux=True``, stdout and stderr are separated.
``demux=True``, a tuple with two elements of type byte: stdout and
stderr.
Raises:
:py:class:`docker.errors.APIError`
Expand Down
33 changes: 23 additions & 10 deletions docker/api/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,15 @@ def inspect_image(self, image):

@utils.minimum_version('1.30')
@utils.check_resource('image')
def inspect_distribution(self, image):
def inspect_distribution(self, image, auth_config=None):
"""
Get image digest and platform information by contacting the registry.
Args:
image (str): The image name to inspect
auth_config (dict): Override the credentials that are found in the
config for this request. ``auth_config`` should contain the
``username`` and ``password`` keys to be valid.
Returns:
(dict): A dict containing distribution data
Expand All @@ -261,9 +264,21 @@ def inspect_distribution(self, image):
:py:class:`docker.errors.APIError`
If the server returns an error.
"""
registry, _ = auth.resolve_repository_name(image)

headers = {}
if auth_config is None:
header = auth.get_config_header(self, registry)
if header:
headers['X-Registry-Auth'] = header
else:
log.debug('Sending supplied auth config')
headers['X-Registry-Auth'] = auth.encode_header(auth_config)

url = self._url("/distribution/{0}/json", image)

return self._result(
self._get(self._url("/distribution/{0}/json", image)), True
self._get(url, headers=headers), True
)

def load_image(self, data, quiet=None):
Expand Down Expand Up @@ -336,10 +351,9 @@ def pull(self, repository, tag=None, stream=False, auth_config=None,
tag (str): The tag to pull
stream (bool): Stream the output as a generator. Make sure to
consume the generator, otherwise pull might get cancelled.
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.
auth_config (dict): Override the credentials that are found in the
config 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]]``
Expand Down Expand Up @@ -414,10 +428,9 @@ def push(self, repository, tag=None, stream=False, auth_config=None,
repository (str): The repository to push to
tag (str): An optional tag to push
stream (bool): Stream the output as a blocking generator
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.
auth_config (dict): Override the credentials that are found in the
config 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``
Expand Down
9 changes: 6 additions & 3 deletions docker/api/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ def raise_version_error(param, min_version):
if container_spec.get('Isolation') is not None:
raise_version_error('ContainerSpec.isolation', '1.35')

if utils.version_lt(version, '1.38'):
if container_spec.get('Init') is not None:
raise_version_error('ContainerSpec.init', '1.38')

if task_template.get('Resources'):
if utils.version_lt(version, '1.32'):
if task_template['Resources'].get('GenericResources'):
Expand Down Expand Up @@ -387,7 +391,7 @@ def update_service(self, service, version, task_template=None, name=None,
current specification of the service. Default: ``False``
Returns:
``True`` if successful.
A dictionary containing a ``Warnings`` key.
Raises:
:py:class:`docker.errors.APIError`
Expand Down Expand Up @@ -471,5 +475,4 @@ def update_service(self, service, version, task_template=None, name=None,
resp = self._post_json(
url, data=data, params={'version': version}, headers=headers
)
self._raise_for_status(resp)
return True
return self._result(resp, json=True)
Loading

0 comments on commit 5d42ab8

Please sign in to comment.