Skip to content

Commit 5cc7cc1

Browse files
committed
Merge pull request #474 from gierschv/fix-build-remote
Fix crash when building from remote sources
2 parents 3e1dded + f3717f5 commit 5cc7cc1

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

docker/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,8 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
450450
# Send the full auth configuration (if any exists), since the build
451451
# could use any (or all) of the registries.
452452
if self._auth_configs:
453+
if headers is None:
454+
headers = {}
453455
headers['X-Registry-Config'] = auth.encode_full_header(
454456
self._auth_configs
455457
)

tests/test.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2003,6 +2003,20 @@ def test_build_container_custom_context_gzip(self):
20032003
except Exception as e:
20042004
self.fail('Command should not raise exception: {0}'.format(e))
20052005

2006+
def test_build_remote_with_registry_auth(self):
2007+
try:
2008+
self.client._auth_configs = {
2009+
'https://example.com': {
2010+
'user': 'example',
2011+
'password': 'example',
2012+
'email': '[email protected]'
2013+
}
2014+
}
2015+
2016+
self.client.build(path='https://github.com/docker-library/mongo')
2017+
except Exception as e:
2018+
self.fail('Command should not raise exception: {0}'.format(e))
2019+
20062020
#######################
20072021
# PY SPECIFIC TESTS #
20082022
#######################

0 commit comments

Comments
 (0)