Fix crash when building from remote sources

Avoid crashing when the Docker python client is able to load
registry credentials when building using a remote source

Signed-off-by: Vincent Giersch <vincent.giersch@ovh.net>
This commit is contained in:
Vincent Giersch 2015-02-04 16:22:17 +00:00
parent 39ee2d55b2
commit f3717f5815
2 changed files with 16 additions and 0 deletions

View File

@ -450,6 +450,8 @@ class Client(requests.Session):
# Send the full auth configuration (if any exists), since the build
# could use any (or all) of the registries.
if self._auth_configs:
if headers is None:
headers = {}
headers['X-Registry-Config'] = auth.encode_full_header(
self._auth_configs
)

View File

@ -2003,6 +2003,20 @@ class DockerClientTest(Cleanup, unittest.TestCase):
except Exception as e:
self.fail('Command should not raise exception: {0}'.format(e))
def test_build_remote_with_registry_auth(self):
try:
self.client._auth_configs = {
'https://example.com': {
'user': 'example',
'password': 'example',
'email': 'example@example.com'
}
}
self.client.build(path='https://github.com/docker-library/mongo')
except Exception as e:
self.fail('Command should not raise exception: {0}'.format(e))
#######################
# PY SPECIFIC TESTS #
#######################