From ebcfab0a4c1430846de1b26a114570e4eb0d6a1a Mon Sep 17 00:00:00 2001 From: Matt Outten Date: Fri, 17 Jul 2015 15:48:52 -0400 Subject: [PATCH 1/2] Switch to send full AuthConfig object for build action In order to support the docker API for version 1.7+, this command changes the way the `X-Registry-Config` header is sent when attempting to build an image. --- docker/auth/auth.py | 6 ------ docker/client.py | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/docker/auth/auth.py b/docker/auth/auth.py index 1c29615546..d7fbd6b83f 100644 --- a/docker/auth/auth.py +++ b/docker/auth/auth.py @@ -102,12 +102,6 @@ def encode_header(auth): return base64.b64encode(auth_json) -def encode_full_header(auth): - """ Returns the given auth block encoded for the X-Registry-Config header. - """ - return encode_header({'configs': auth}) - - def parse_auth(entries): """ Parses authentication entries diff --git a/docker/client.py b/docker/client.py index e52cb53829..ce4a657139 100644 --- a/docker/client.py +++ b/docker/client.py @@ -139,7 +139,7 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None, if self._auth_configs: if headers is None: headers = {} - headers['X-Registry-Config'] = auth.encode_full_header( + headers['X-Registry-Config'] = auth.encode_header( self._auth_configs ) From 4be228653df9028bef4a288148d392d7e9b0448a Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Mon, 20 Jul 2015 14:06:33 -0700 Subject: [PATCH 2/2] Make build auth work with API versions < 1.19 too --- docker/client.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/docker/client.py b/docker/client.py index 7fe72db2f8..41dd03aee2 100644 --- a/docker/client.py +++ b/docker/client.py @@ -140,9 +140,14 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None, if self._auth_configs: if headers is None: headers = {} - headers['X-Registry-Config'] = auth.encode_header( - self._auth_configs - ) + if utils.compare_version('1.19', self._version) >= 0: + headers['X-Registry-Config'] = auth.encode_header( + self._auth_configs + ) + else: + headers['X-Registry-Config'] = auth.encode_header({ + 'configs': self._auth_configs + }) response = self._post( u,