Skip to content

Commit

Permalink
Merge pull request #2443 from docker/4.1.0-release
Browse files Browse the repository at this point in the history
4.1.0 release
  • Loading branch information
chris-crone committed Oct 3, 2019
2 parents 1308cfb + 2bb08b3 commit 6649587
Show file tree
Hide file tree
Showing 38 changed files with 453 additions and 248 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
@@ -1,4 +1,6 @@
FROM python:2.7
ARG PYTHON_VERSION=2.7

FROM python:${PYTHON_VERSION}

RUN mkdir /src
WORKDIR /src
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile-docs
@@ -1,4 +1,6 @@
FROM python:3.5
ARG PYTHON_VERSION=3.7

FROM python:${PYTHON_VERSION}

ARG uid=1000
ARG gid=1000
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile-py3
@@ -1,4 +1,6 @@
FROM python:3.6
ARG PYTHON_VERSION=3.7

FROM python:${PYTHON_VERSION}

RUN mkdir /src
WORKDIR /src
Expand Down
10 changes: 6 additions & 4 deletions Jenkinsfile
Expand Up @@ -25,7 +25,7 @@ def buildImages = { ->
imageNamePy3 = "${imageNameBase}:py3-${gitCommit()}"

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")
buildImage(imageNamePy3, "-f tests/Dockerfile --build-arg PYTHON_VERSION=3.7 .", "py3.7")
}
}
}
Expand All @@ -46,12 +46,14 @@ def getDockerVersions = { ->

def getAPIVersion = { engineVersion ->
def versionMap = [
'17.06': '1.30', '17.12': '1.35', '18.02': '1.36', '18.03': '1.37',
'18.06': '1.38', '18.09': '1.39'
'17.06': '1.30',
'18.03': '1.37',
'18.09': '1.39',
'19.03': '1.40'
]
def result = versionMap[engineVersion.substring(0, 5)]
if (!result) {
return '1.39'
return '1.40'
}
return result
}
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -8,11 +8,11 @@ clean:

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

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

.PHONY: build-docs
build-docs:
Expand Down
3 changes: 2 additions & 1 deletion docker/api/build.py
Expand Up @@ -308,7 +308,8 @@ def _set_auth_headers(self, headers):
auth_data = self._auth_configs.get_all_credentials()

# See https://github.com/docker/docker-py/issues/1683
if auth.INDEX_URL not in auth_data and auth.INDEX_URL in auth_data:
if (auth.INDEX_URL not in auth_data and
auth.INDEX_NAME in auth_data):
auth_data[auth.INDEX_URL] = auth_data.get(auth.INDEX_NAME, {})

log.debug(
Expand Down
4 changes: 3 additions & 1 deletion docker/api/container.py
Expand Up @@ -174,7 +174,8 @@ def containers(self, quiet=False, all=False, trunc=False, latest=False,
- `exited` (int): Only containers with specified exit code
- `status` (str): One of ``restarting``, ``running``,
``paused``, ``exited``
- `label` (str): format either ``"key"`` or ``"key=value"``
- `label` (str|list): format either ``"key"``, ``"key=value"``
or a list of such.
- `id` (str): The id of the container.
- `name` (str): The name of the container.
- `ancestor` (str): Filter by container ancestor. Format of
Expand Down Expand Up @@ -502,6 +503,7 @@ def create_host_config(self, *args, **kwargs):
bytes) or a string with a units identification char
(``100000b``, ``1000k``, ``128m``, ``1g``). If a string is
specified without a units character, bytes are assumed as an
mem_reservation (int or str): Memory soft limit.
mem_swappiness (int): Tune a container's memory swappiness
behavior. Accepts number between 0 and 100.
memswap_limit (str or int): Maximum amount of memory + swap a
Expand Down
3 changes: 2 additions & 1 deletion docker/api/image.py
Expand Up @@ -70,7 +70,8 @@ def images(self, name=None, quiet=False, all=False, filters=None):
filters (dict): Filters to be processed on the image list.
Available filters:
- ``dangling`` (bool)
- ``label`` (str): format either ``key`` or ``key=value``
- `label` (str|list): format either ``"key"``, ``"key=value"``
or a list of such.
Returns:
(dict or list): A list if ``quiet=True``, otherwise a dict.
Expand Down
5 changes: 3 additions & 2 deletions docker/api/network.py
Expand Up @@ -7,15 +7,16 @@
class NetworkApiMixin(object):
def networks(self, names=None, ids=None, filters=None):
"""
List networks. Similar to the ``docker networks ls`` command.
List networks. Similar to the ``docker network ls`` command.
Args:
names (:py:class:`list`): List of names to filter by
ids (:py:class:`list`): List of ids to filter by
filters (dict): Filters to be processed on the network list.
Available filters:
- ``driver=[<driver-name>]`` Matches a network's driver.
- ``label=[<key>]`` or ``label=[<key>=<value>]``.
- ``label=[<key>]``, ``label=[<key>=<value>]`` or a list of
such.
- ``type=["custom"|"builtin"]`` Filters networks by type.
Returns:
Expand Down
10 changes: 6 additions & 4 deletions docker/api/service.py
Expand Up @@ -135,8 +135,9 @@ def create_service(
of the service. Default: ``None``
rollback_config (RollbackConfig): Specification for the rollback
strategy of the service. Default: ``None``
networks (:py:class:`list`): List of network names or IDs to attach
the service to. Default: ``None``.
networks (:py:class:`list`): List of network names or IDs or
:py:class:`~docker.types.NetworkAttachmentConfig` to attach the
service to. Default: ``None``.
endpoint_spec (EndpointSpec): Properties that can be configured to
access and load balance a service. Default: ``None``.
Expand Down Expand Up @@ -383,8 +384,9 @@ def update_service(self, service, version, task_template=None, name=None,
of the service. Default: ``None``.
rollback_config (RollbackConfig): Specification for the rollback
strategy of the service. Default: ``None``
networks (:py:class:`list`): List of network names or IDs to attach
the service to. Default: ``None``.
networks (:py:class:`list`): List of network names or IDs or
:py:class:`~docker.types.NetworkAttachmentConfig` to attach the
service to. Default: ``None``.
endpoint_spec (EndpointSpec): Properties that can be configured to
access and load balance a service. Default: ``None``.
fetch_current_spec (boolean): Use the undefined settings from the
Expand Down
2 changes: 2 additions & 0 deletions docker/auth.py
Expand Up @@ -303,12 +303,14 @@ def get_all_credentials(self):
auth_data[k] = self._resolve_authconfig_credstore(
k, self.creds_store
)
auth_data[convert_to_hostname(k)] = auth_data[k]

# credHelpers entries take priority over all others
for reg, store_name in self.cred_helpers.items():
auth_data[reg] = self._resolve_authconfig_credstore(
reg, store_name
)
auth_data[convert_to_hostname(reg)] = auth_data[reg]

return auth_data

Expand Down
5 changes: 3 additions & 2 deletions docker/models/containers.py
Expand Up @@ -618,7 +618,7 @@ def run(self, image, command=None, stdout=True, stderr=False,
(``100000b``, ``1000k``, ``128m``, ``1g``). If a string is
specified without a units character, bytes are assumed as an
intended unit.
mem_reservation (int or str): Memory soft limit
mem_reservation (int or str): Memory soft limit.
mem_swappiness (int): Tune a container's memory swappiness
behavior. Accepts number between 0 and 100.
memswap_limit (str or int): Maximum amount of memory + swap a
Expand Down Expand Up @@ -900,7 +900,8 @@ def list(self, all=False, before=None, filters=None, limit=-1, since=None,
- `exited` (int): Only containers with specified exit code
- `status` (str): One of ``restarting``, ``running``,
``paused``, ``exited``
- `label` (str): format either ``"key"`` or ``"key=value"``
- `label` (str|list): format either ``"key"``, ``"key=value"``
or a list of such.
- `id` (str): The id of the container.
- `name` (str): The name of the container.
- `ancestor` (str): Filter by container ancestor. Format of
Expand Down
3 changes: 2 additions & 1 deletion docker/models/images.py
Expand Up @@ -350,7 +350,8 @@ def list(self, name=None, all=False, filters=None):
filters (dict): Filters to be processed on the image list.
Available filters:
- ``dangling`` (bool)
- ``label`` (str): format either ``key`` or ``key=value``
- `label` (str|list): format either ``"key"``, ``"key=value"``
or a list of such.
Returns:
(list of :py:class:`Image`): The images.
Expand Down
3 changes: 2 additions & 1 deletion docker/models/networks.py
Expand Up @@ -190,7 +190,8 @@ def list(self, *args, **kwargs):
filters (dict): Filters to be processed on the network list.
Available filters:
- ``driver=[<driver-name>]`` Matches a network's driver.
- ``label=[<key>]`` or ``label=[<key>=<value>]``.
- `label` (str|list): format either ``"key"``, ``"key=value"``
or a list of such.
- ``type=["custom"|"builtin"]`` Filters networks by type.
greedy (bool): Fetch more details for each network individually.
You might want this to get the containers attached to them.
Expand Down
12 changes: 7 additions & 5 deletions docker/models/services.py
Expand Up @@ -178,11 +178,12 @@ def create(self, image, command=None, **kwargs):
``source:target:options``, where options is either
``ro`` or ``rw``.
name (str): Name to give to the service.
networks (list of str): List of network names or IDs to attach
the service to. Default: ``None``.
networks (:py:class:`list`): List of network names or IDs or
:py:class:`~docker.types.NetworkAttachmentConfig` to attach the
service to. Default: ``None``.
resources (Resources): Resource limits and reservations.
restart_policy (RestartPolicy): Restart policy for containers.
secrets (list of :py:class:`docker.types.SecretReference`): List
secrets (list of :py:class:`~docker.types.SecretReference`): List
of secrets accessible to containers for this service.
stop_grace_period (int): Amount of time to wait for
containers to terminate before forcefully killing them.
Expand All @@ -205,8 +206,9 @@ def create(self, image, command=None, **kwargs):
the container's `hosts` file.
dns_config (DNSConfig): Specification for DNS
related configurations in resolver configuration file.
configs (:py:class:`list`): List of :py:class:`ConfigReference`
that will be exposed to the service.
configs (:py:class:`list`): List of
:py:class:`~docker.types.ConfigReference` that will be exposed
to the service.
privileges (Privileges): Security options for the service's
containers.
Expand Down
2 changes: 1 addition & 1 deletion docker/types/__init__.py
Expand Up @@ -7,6 +7,6 @@
ConfigReference, ContainerSpec, DNSConfig, DriverConfig, EndpointSpec,
Mount, Placement, PlacementPreference, Privileges, Resources,
RestartPolicy, RollbackConfig, SecretReference, ServiceMode, TaskTemplate,
UpdateConfig
UpdateConfig, NetworkAttachmentConfig
)
from .swarm import SwarmSpec, SwarmExternalCA
22 changes: 20 additions & 2 deletions docker/types/services.py
Expand Up @@ -26,8 +26,8 @@ class TaskTemplate(dict):
placement (Placement): Placement instructions for the scheduler.
If a list is passed instead, it is assumed to be a list of
constraints as part of a :py:class:`Placement` object.
networks (:py:class:`list`): List of network names or IDs to attach
the containers to.
networks (:py:class:`list`): List of network names or IDs or
:py:class:`NetworkAttachmentConfig` to attach the service to.
force_update (int): A counter that triggers an update even if no
relevant parameters have been changed.
"""
Expand Down Expand Up @@ -770,3 +770,21 @@ def __init__(self, credentialspec_file=None, credentialspec_registry=None,

if len(selinux_context) > 0:
self['SELinuxContext'] = selinux_context


class NetworkAttachmentConfig(dict):
"""
Network attachment options for a service.
Args:
target (str): The target network for attachment.
Can be a network name or ID.
aliases (:py:class:`list`): A list of discoverable alternate names
for the service.
options (:py:class:`dict`): Driver attachment options for the
network target.
"""
def __init__(self, target, aliases=None, options=None):
self['Target'] = target
self['Aliases'] = aliases
self['DriverOpts'] = options
2 changes: 1 addition & 1 deletion docker/version.py
@@ -1,2 +1,2 @@
version = "4.0.2"
version = "4.1.0"
version_info = tuple([int(d) for d in version.split("-")[0].split(".")])
1 change: 1 addition & 0 deletions docs/api.rst
Expand Up @@ -142,6 +142,7 @@ Configuration types
.. autoclass:: IPAMPool
.. autoclass:: LogConfig
.. autoclass:: Mount
.. autoclass:: NetworkAttachmentConfig
.. autoclass:: Placement
.. autoclass:: PlacementPreference
.. autoclass:: Privileges
Expand Down
21 changes: 21 additions & 0 deletions docs/change-log.md
@@ -1,6 +1,27 @@
Change log
==========

4.1.0
-----

[List of PRs / issues for this release](https://github.com/docker/docker-py/milestone/61?closed=1)

### Bugfixes

- Correct `INDEX_URL` logic in build.py _set_auth_headers
- Fix for empty auth keys in config.json

### Features

- Add `NetworkAttachmentConfig` for service create/update

### Miscellaneous

- Bump pytest to 4.3.1
- Adjust `--platform` tests for changes in docker engine
- Update credentials-helpers to v0.6.3


4.0.2
-----

Expand Down
3 changes: 3 additions & 0 deletions pytest.ini
@@ -1,2 +1,5 @@
[pytest]
addopts = --tb=short -rxs

junit_suite_name = docker-py
junit_family = xunit2
2 changes: 1 addition & 1 deletion test-requirements.txt
@@ -1,6 +1,6 @@
coverage==4.5.2
flake8==3.6.0
mock==1.0.1
pytest==4.1.0
pytest==4.3.1
pytest-cov==2.6.1
pytest-timeout==1.3.3
14 changes: 10 additions & 4 deletions tests/Dockerfile
@@ -1,5 +1,11 @@
ARG PYTHON_VERSION=3.6
FROM python:$PYTHON_VERSION-jessie
ARG PYTHON_VERSION=3.7

FROM python:${PYTHON_VERSION}

ARG APT_MIRROR
RUN sed -ri "s/(httpredir|deb).debian.org/${APT_MIRROR:-deb.debian.org}/g" /etc/apt/sources.list \
&& sed -ri "s/(security).debian.org/${APT_MIRROR:-security.debian.org}/g" /etc/apt/sources.list

RUN apt-get update && apt-get -y install \
gnupg2 \
pass \
Expand All @@ -8,9 +14,9 @@ RUN apt-get update && apt-get -y install \
COPY ./tests/gpg-keys /gpg-keys
RUN gpg2 --import gpg-keys/secret
RUN gpg2 --import-ownertrust gpg-keys/ownertrust
RUN yes | pass init $(gpg2 --no-auto-check-trustdb --list-secret-keys | grep ^sec | cut -d/ -f2 | cut -d" " -f1)
RUN yes | pass init $(gpg2 --no-auto-check-trustdb --list-secret-key | awk '/^sec/{getline; $1=$1; print}')
RUN gpg2 --check-trustdb
ARG CREDSTORE_VERSION=v0.6.0
ARG CREDSTORE_VERSION=v0.6.3
RUN curl -sSL -o /opt/docker-credential-pass.tar.gz \
https://github.com/docker/docker-credential-helpers/releases/download/$CREDSTORE_VERSION/docker-credential-pass-$CREDSTORE_VERSION-amd64.tar.gz && \
tar -xf /opt/docker-credential-pass.tar.gz -O > /usr/local/bin/docker-credential-pass && \
Expand Down
4 changes: 3 additions & 1 deletion tests/Dockerfile-dind-certs
@@ -1,4 +1,6 @@
FROM python:2.7
ARG PYTHON_VERSION=2.7

FROM python:${PYTHON_VERSION}
RUN mkdir /tmp/certs
VOLUME /certs

Expand Down
10 changes: 6 additions & 4 deletions tests/integration/api_build_test.py
Expand Up @@ -9,7 +9,7 @@
import pytest
import six

from .base import BaseAPIIntegrationTest, BUSYBOX
from .base import BaseAPIIntegrationTest, TEST_IMG
from ..helpers import random_name, requires_api_version, requires_experimental


Expand Down Expand Up @@ -277,7 +277,7 @@ def test_build_with_network_mode(self):
# Set up pingable endpoint on custom network
network = self.client.create_network(random_name())['Id']
self.tmp_networks.append(network)
container = self.client.create_container(BUSYBOX, 'top')
container = self.client.create_container(TEST_IMG, 'top')
self.tmp_containers.append(container)
self.client.start(container)
self.client.connect_container_to_network(
Expand Down Expand Up @@ -448,8 +448,10 @@ def test_build_invalid_platform(self):
for _ in stream:
pass

assert excinfo.value.status_code == 400
assert 'invalid platform' in excinfo.exconly()
# Some API versions incorrectly returns 500 status; assert 4xx or 5xx
assert excinfo.value.is_error()
assert 'unknown operating system' in excinfo.exconly() \
or 'invalid platform' in excinfo.exconly()

def test_build_out_of_context_dockerfile(self):
base_dir = tempfile.mkdtemp()
Expand Down

0 comments on commit 6649587

Please sign in to comment.