Pass X-Registry-Auth when building an image

* Initialize headers variable in BuildApiMixin.build() as a dict rather
  than as None.  This way the correct object gets passed to
  _set_auth_headers() even if no headers were set in build()

* Changing object from None to {} in BuildApiMixin._set_auth_headers()
  removed because it changes the object reference, so has no effect on
  calling code.

Signed-off-by: Justin Michalicek <jmichalicek@gmail.com>
This commit is contained in:
Justin Michalicek 2016-07-06 16:10:16 -04:00
parent 5e47026a9b
commit 66e7af9353
1 changed files with 3 additions and 3 deletions

View File

@ -18,7 +18,8 @@ class BuildApiMixin(object):
custom_context=False, encoding=None, pull=False,
forcerm=False, dockerfile=None, container_limits=None,
decode=False, buildargs=None, gzip=False):
remote = context = headers = None
remote = context = None
headers = {}
container_limits = container_limits or {}
if path is None and fileobj is None:
raise TypeError("Either path or fileobj needs to be provided.")
@ -134,8 +135,7 @@ class BuildApiMixin(object):
', '.join(repr(k) for k in self._auth_configs.keys())
)
)
if headers is None:
headers = {}
if utils.compare_version('1.19', self._version) >= 0:
headers['X-Registry-Config'] = auth.encode_header(
self._auth_configs