Kaydet (Commit) 0f843414 authored tarafından Erik Johnson's avatar Erik Johnson

Add a reload_config function to the DaemonApiMixin

This allows the client to reload the config.json for an existing
APIClient instance.
Signed-off-by: 's avatarErik Johnson <palehose@gmail.com>
üst 72b9b723
...@@ -123,9 +123,9 @@ class DaemonApiMixin(object): ...@@ -123,9 +123,9 @@ class DaemonApiMixin(object):
# If dockercfg_path is passed check to see if the config file exists, # If dockercfg_path is passed check to see if the config file exists,
# if so load that config. # if so load that config.
if dockercfg_path and os.path.exists(dockercfg_path): if dockercfg_path and os.path.exists(dockercfg_path):
self._auth_configs = auth.load_config(dockercfg_path) self._auth_configs = self.reload_config(dockercfg_path)
elif not self._auth_configs: elif not self._auth_configs:
self._auth_configs = auth.load_config() self._auth_configs = self.reload_config()
authcfg = auth.resolve_authconfig(self._auth_configs, registry) authcfg = auth.resolve_authconfig(self._auth_configs, registry)
# If we found an existing auth config for this registry and username # If we found an existing auth config for this registry and username
...@@ -174,3 +174,17 @@ class DaemonApiMixin(object): ...@@ -174,3 +174,17 @@ class DaemonApiMixin(object):
""" """
url = self._url("/version", versioned_api=api_version) url = self._url("/version", versioned_api=api_version)
return self._result(self._get(url), json=True) return self._result(self._get(url), json=True)
def reload_config(self, dockercfg_path=None):
"""
Forces a reload of the auth configuration
Args:
dockercfg_path (str): Use a custom path for the Docker config file
(default ``$HOME/.docker/config.json`` if present,
otherwise``$HOME/.dockercfg``)
Returns:
None
"""
self._auth_configs = auth.load_config(dockercfg_path)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment