Skip to content

Commit fc481c4

Browse files
authored
Merge pull request #1220 from docker/1.10.3-release
1.10.3 release
2 parents e833881 + 64fba72 commit fc481c4

File tree

8 files changed

+86
-18
lines changed

8 files changed

+86
-18
lines changed

docker/auth/auth.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,15 @@ def parse_auth(entries, raise_on_error=False):
174174
'Invalid configuration for registry {0}'.format(registry)
175175
)
176176
return {}
177+
if 'identitytoken' in entry:
178+
log.debug('Found an IdentityToken entry for registry {0}'.format(
179+
registry
180+
))
181+
conf[registry] = {
182+
'IdentityToken': entry['identitytoken']
183+
}
184+
continue # Other values are irrelevant if we have a token, skip.
185+
177186
if 'auth' not in entry:
178187
# Starting with engine v1.11 (API 1.23), an empty dictionary is
179188
# a valid value in the auths config.
@@ -182,13 +191,15 @@ def parse_auth(entries, raise_on_error=False):
182191
'Auth data for {0} is absent. Client might be using a '
183192
'credentials store instead.'
184193
)
185-
return {}
194+
conf[registry] = {}
195+
continue
186196

187197
username, password = decode_auth(entry['auth'])
188198
log.debug(
189199
'Found entry (registry={0}, username={1})'
190200
.format(repr(registry), repr(username))
191201
)
202+
192203
conf[registry] = {
193204
'username': username,
194205
'password': password,

docker/client.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ class Client(
4040
api.VolumeApiMixin):
4141
def __init__(self, base_url=None, version=None,
4242
timeout=constants.DEFAULT_TIMEOUT_SECONDS, tls=False,
43-
user_agent=constants.DEFAULT_USER_AGENT):
43+
user_agent=constants.DEFAULT_USER_AGENT,
44+
num_pools=constants.DEFAULT_NUM_POOLS):
4445
super(Client, self).__init__()
4546

4647
if tls and not base_url:
@@ -58,7 +59,9 @@ def __init__(self, base_url=None, version=None,
5859
base_url, constants.IS_WINDOWS_PLATFORM, tls=bool(tls)
5960
)
6061
if base_url.startswith('http+unix://'):
61-
self._custom_adapter = UnixAdapter(base_url, timeout)
62+
self._custom_adapter = UnixAdapter(
63+
base_url, timeout, num_pools=num_pools
64+
)
6265
self.mount('http+docker://', self._custom_adapter)
6366
self._unmount('http://', 'https://')
6467
self.base_url = 'http+docker://localunixsocket'
@@ -68,7 +71,9 @@ def __init__(self, base_url=None, version=None,
6871
'The npipe:// protocol is only supported on Windows'
6972
)
7073
try:
71-
self._custom_adapter = NpipeAdapter(base_url, timeout)
74+
self._custom_adapter = NpipeAdapter(
75+
base_url, timeout, num_pools=num_pools
76+
)
7277
except NameError:
7378
raise errors.DockerException(
7479
'Install pypiwin32 package to enable npipe:// support'
@@ -80,7 +85,9 @@ def __init__(self, base_url=None, version=None,
8085
if isinstance(tls, TLSConfig):
8186
tls.configure_client(self)
8287
elif tls:
83-
self._custom_adapter = ssladapter.SSLAdapter()
88+
self._custom_adapter = ssladapter.SSLAdapter(
89+
num_pools=num_pools
90+
)
8491
self.mount('https://', self._custom_adapter)
8592
self.base_url = base_url
8693

docker/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
IS_WINDOWS_PLATFORM = (sys.platform == 'win32')
1616

1717
DEFAULT_USER_AGENT = "docker-py/{0}".format(version)
18+
DEFAULT_NUM_POOLS = 25

docker/transport/npipeconn.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import six
22
import requests.adapters
33

4+
from .. import constants
45
from .npipesocket import NpipeSocket
56

67
if six.PY3:
@@ -33,9 +34,9 @@ def connect(self):
3334

3435

3536
class NpipeHTTPConnectionPool(urllib3.connectionpool.HTTPConnectionPool):
36-
def __init__(self, npipe_path, timeout=60):
37+
def __init__(self, npipe_path, timeout=60, maxsize=10):
3738
super(NpipeHTTPConnectionPool, self).__init__(
38-
'localhost', timeout=timeout
39+
'localhost', timeout=timeout, maxsize=maxsize
3940
)
4041
self.npipe_path = npipe_path
4142
self.timeout = timeout
@@ -47,11 +48,12 @@ def _new_conn(self):
4748

4849

4950
class NpipeAdapter(requests.adapters.HTTPAdapter):
50-
def __init__(self, base_url, timeout=60):
51+
def __init__(self, base_url, timeout=60,
52+
num_pools=constants.DEFAULT_NUM_POOLS):
5153
self.npipe_path = base_url.replace('npipe://', '')
5254
self.timeout = timeout
5355
self.pools = RecentlyUsedContainer(
54-
10, dispose_func=lambda p: p.close()
56+
num_pools, dispose_func=lambda p: p.close()
5557
)
5658
super(NpipeAdapter, self).__init__()
5759

docker/transport/unixconn.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import requests.adapters
33
import socket
44

5+
from .. import constants
6+
57
if six.PY3:
68
import http.client as httplib
79
else:
@@ -12,6 +14,7 @@
1214
except ImportError:
1315
import urllib3
1416

17+
1518
RecentlyUsedContainer = urllib3._collections.RecentlyUsedContainer
1619

1720

@@ -32,28 +35,31 @@ def connect(self):
3235

3336

3437
class UnixHTTPConnectionPool(urllib3.connectionpool.HTTPConnectionPool):
35-
def __init__(self, base_url, socket_path, timeout=60):
38+
def __init__(self, base_url, socket_path, timeout=60, maxsize=10):
3639
super(UnixHTTPConnectionPool, self).__init__(
37-
'localhost', timeout=timeout
40+
'localhost', timeout=timeout, maxsize=maxsize
3841
)
3942
self.base_url = base_url
4043
self.socket_path = socket_path
4144
self.timeout = timeout
4245

4346
def _new_conn(self):
44-
return UnixHTTPConnection(self.base_url, self.socket_path,
45-
self.timeout)
47+
return UnixHTTPConnection(
48+
self.base_url, self.socket_path, self.timeout
49+
)
4650

4751

4852
class UnixAdapter(requests.adapters.HTTPAdapter):
49-
def __init__(self, socket_url, timeout=60):
53+
def __init__(self, socket_url, timeout=60,
54+
num_pools=constants.DEFAULT_NUM_POOLS):
5055
socket_path = socket_url.replace('http+unix://', '')
5156
if not socket_path.startswith('/'):
5257
socket_path = '/' + socket_path
5358
self.socket_path = socket_path
5459
self.timeout = timeout
55-
self.pools = RecentlyUsedContainer(10,
56-
dispose_func=lambda p: p.close())
60+
self.pools = RecentlyUsedContainer(
61+
num_pools, dispose_func=lambda p: p.close()
62+
)
5763
super(UnixAdapter, self).__init__()
5864

5965
def get_connection(self, url, proxies=None):

docker/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version = "1.10.2"
1+
version = "1.10.3"
22
version_info = tuple([int(d) for d in version.split("-")[0].split(".")])

docs/change_log.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
Change Log
22
==========
33

4+
1.10.3
5+
------
6+
7+
[List of PRs / issues for this release](https://github.com/docker/docker-py/issues?q=milestone%3A1.10.3+is%3Aclosed)
8+
9+
### Bugfixes
10+
11+
* Fixed an issue where identity tokens in configuration files weren't handled
12+
by the library.
13+
14+
### Miscellaneous
15+
16+
* Increased the default number of connection pools from 10 to 25. This number
17+
can now be configured using the `num_pools` parameter in the `Client`
18+
constructor.
19+
20+
421
1.10.2
522
------
623

tests/unit/auth_test.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,4 +460,28 @@ def test_load_config_invalid_auth_dict(self):
460460
json.dump(config, f)
461461

462462
cfg = auth.load_config(dockercfg_path)
463-
assert cfg == {}
463+
assert cfg == {'scarlet.net': {}}
464+
465+
def test_load_config_identity_token(self):
466+
folder = tempfile.mkdtemp()
467+
registry = 'scarlet.net'
468+
token = '1ce1cebb-503e-7043-11aa-7feb8bd4a1ce'
469+
self.addCleanup(shutil.rmtree, folder)
470+
dockercfg_path = os.path.join(folder, 'config.json')
471+
auth_entry = encode_auth({'username': 'sakuya'}).decode('ascii')
472+
config = {
473+
'auths': {
474+
registry: {
475+
'auth': auth_entry,
476+
'identitytoken': token
477+
}
478+
}
479+
}
480+
with open(dockercfg_path, 'w') as f:
481+
json.dump(config, f)
482+
483+
cfg = auth.load_config(dockercfg_path)
484+
assert registry in cfg
485+
cfg = cfg[registry]
486+
assert 'IdentityToken' in cfg
487+
assert cfg['IdentityToken'] == token

0 commit comments

Comments
 (0)