summaryrefslogtreecommitdiff
path: root/docker/api/image.py
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2016-08-22 19:12:27 -0700
committerJoffrey F <joffrey@docker.com>2016-08-23 14:52:07 -0700
commit775b581c04dfa5f7d421ad74f969f25869fa8151 (patch)
tree4852aea751667ba0b127c111aac95d61b0e0b96f /docker/api/image.py
parent7d5a1eeb7a46f17136aaf1041660d043a85051fc (diff)
downloaddocker-py-1085-service-support.tar.gz
Private images support in create_service / update_service1085-service-support
Refactor auth header computation Add tasks methods and documentation. Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'docker/api/image.py')
-rw-r--r--docker/api/image.py41
1 files changed, 6 insertions, 35 deletions
diff --git a/docker/api/image.py b/docker/api/image.py
index 2bdbce8..4d6561e 100644
--- a/docker/api/image.py
+++ b/docker/api/image.py
@@ -166,28 +166,10 @@ class ImageApiMixin(object):
headers = {}
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 auth_config is None:
- log.debug('Looking for auth config')
- if not self._auth_configs:
- log.debug(
- "No auth config in memory - loading from filesystem"
- )
- 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:
- log.debug('Found auth config')
- # 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(
- authcfg
- )
- else:
- log.debug('No auth config found')
+ header = auth.get_config_header(self, registry)
+ if header:
+ headers['X-Registry-Auth'] = header
else:
log.debug('Sending supplied auth config')
headers['X-Registry-Auth'] = auth.encode_header(auth_config)
@@ -222,21 +204,10 @@ class ImageApiMixin(object):
headers = {}
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 auth_config is None:
- log.debug('Looking for auth config')
- if not self._auth_configs:
- log.debug(
- "No auth config in memory - loading from filesystem"
- )
- 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)
+ header = auth.get_config_header(self, registry)
+ if header:
+ headers['X-Registry-Auth'] = header
else:
log.debug('Sending supplied auth config')
headers['X-Registry-Auth'] = auth.encode_header(auth_config)