summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2015-04-22 11:18:46 -0700
committerJoffrey F <joffrey@docker.com>2015-04-22 11:18:46 -0700
commit14459560102fb3b541b4b15e3ce8a181ac891fa9 (patch)
treed3228327a95f821d032e8d634d66ccf90c7f2f03
parent9b84e11ae4e044a15a4029e9d1febe3699c41b31 (diff)
parent1685bc45949164b901e05fd3ae7b77107d39ab14 (diff)
downloaddocker-py-14459560102fb3b541b4b15e3ce8a181ac891fa9.tar.gz
Merge branch 'pull_auth' of https://github.com/hibooboo2/docker-py into hibooboo2-pull_auth
-rw-r--r--docker/client.py25
-rw-r--r--docs/api.md1
2 files changed, 16 insertions, 10 deletions
diff --git a/docker/client.py b/docker/client.py
index c20ff3f..dea868d 100644
--- a/docker/client.py
+++ b/docker/client.py
@@ -746,7 +746,7 @@ class Client(requests.Session):
return h_ports
def pull(self, repository, tag=None, stream=False,
- insecure_registry=False):
+ insecure_registry=False, auth_config=None):
if not tag:
repository, tag = utils.parse_repository_tag(repository)
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 we don't have any auth data so far, try reloading the config
# file one more time in case anything showed up in there.
- if not self._auth_configs:
- 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
- # registry as we can have a readonly pull. Just put the header if
- # we can.
- if authcfg:
- headers['X-Registry-Auth'] = auth.encode_header(authcfg)
+ if auth_config is None:
+ if not self._auth_configs:
+ 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 registry as we can have a readonly pull. Just
+ # put the header if we can.
+ if 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,
headers=headers, stream=stream, timeout=None)
diff --git a/docs/api.md b/docs/api.md
index 1d8e5dc..b3a071f 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -502,6 +502,7 @@ Identical to the `docker pull` command.
* tag (str): The tag to pull
* stream (bool): Stream the output as a generator
* 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