mirror of https://github.com/docker/docker-py.git
Merge branch 'pull_auth' of https://github.com/hibooboo2/docker-py into hibooboo2-pull_auth
This commit is contained in:
commit
1445956010
|
|
@ -746,7 +746,7 @@ class Client(requests.Session):
|
||||||
return h_ports
|
return h_ports
|
||||||
|
|
||||||
def pull(self, repository, tag=None, stream=False,
|
def pull(self, repository, tag=None, stream=False,
|
||||||
insecure_registry=False):
|
insecure_registry=False, auth_config=None):
|
||||||
if not tag:
|
if not tag:
|
||||||
repository, tag = utils.parse_repository_tag(repository)
|
repository, tag = utils.parse_repository_tag(repository)
|
||||||
registry, repo_name = auth.resolve_repository_name(
|
registry, repo_name = auth.resolve_repository_name(
|
||||||
|
|
@ -764,15 +764,20 @@ class Client(requests.Session):
|
||||||
if utils.compare_version('1.5', self._version) >= 0:
|
if utils.compare_version('1.5', self._version) >= 0:
|
||||||
# If we don't have any auth data so far, try reloading the config
|
# If we don't have any auth data so far, try reloading the config
|
||||||
# file one more time in case anything showed up in there.
|
# file one more time in case anything showed up in there.
|
||||||
if not self._auth_configs:
|
if auth_config is None:
|
||||||
self._auth_configs = auth.load_config()
|
if not self._auth_configs:
|
||||||
authcfg = auth.resolve_authconfig(self._auth_configs, registry)
|
self._auth_configs = auth.load_config()
|
||||||
|
authcfg = auth.resolve_authconfig(self._auth_configs, registry)
|
||||||
# Do not fail here if no authentication exists for this specific
|
# Do not fail here if no authentication exists for this
|
||||||
# registry as we can have a readonly pull. Just put the header if
|
# specific registry as we can have a readonly pull. Just
|
||||||
# we can.
|
# put the header if we can.
|
||||||
if authcfg:
|
if authcfg:
|
||||||
headers['X-Registry-Auth'] = auth.encode_header(authcfg)
|
# auth_config needs to be a dict in the format used by
|
||||||
|
# auth.py username , password, serveraddress, email
|
||||||
|
headers['X-Registry-Auth'] = auth.encode_header(
|
||||||
|
auth_config)
|
||||||
|
else:
|
||||||
|
headers['X-Registry-Auth'] = auth.encode_header(auth_config)
|
||||||
|
|
||||||
response = self._post(self._url('/images/create'), params=params,
|
response = self._post(self._url('/images/create'), params=params,
|
||||||
headers=headers, stream=stream, timeout=None)
|
headers=headers, stream=stream, timeout=None)
|
||||||
|
|
|
||||||
|
|
@ -502,6 +502,7 @@ Identical to the `docker pull` command.
|
||||||
* tag (str): The tag to pull
|
* tag (str): The tag to pull
|
||||||
* stream (bool): Stream the output as a generator
|
* stream (bool): Stream the output as a generator
|
||||||
* insecure_registry (bool): Use an insecure registry
|
* insecure_registry (bool): Use an insecure registry
|
||||||
|
* auth_config (dict): Override the credentials that Client.login has set for this request
|
||||||
|
|
||||||
**Returns** (generator or str): The output
|
**Returns** (generator or str): The output
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue