Skip to content

Commit 0f84341

Browse files
committed
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: Erik Johnson <[email protected]>
1 parent 72b9b72 commit 0f84341

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

docker/api/daemon.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ def login(self, username, password=None, email=None, registry=None,
123123
# If dockercfg_path is passed check to see if the config file exists,
124124
# if so load that config.
125125
if dockercfg_path and os.path.exists(dockercfg_path):
126-
self._auth_configs = auth.load_config(dockercfg_path)
126+
self._auth_configs = self.reload_config(dockercfg_path)
127127
elif not self._auth_configs:
128-
self._auth_configs = auth.load_config()
128+
self._auth_configs = self.reload_config()
129129

130130
authcfg = auth.resolve_authconfig(self._auth_configs, registry)
131131
# If we found an existing auth config for this registry and username
@@ -174,3 +174,17 @@ def version(self, api_version=True):
174174
"""
175175
url = self._url("/version", versioned_api=api_version)
176176
return self._result(self._get(url), json=True)
177+
178+
def reload_config(self, dockercfg_path=None):
179+
"""
180+
Forces a reload of the auth configuration
181+
182+
Args:
183+
dockercfg_path (str): Use a custom path for the Docker config file
184+
(default ``$HOME/.docker/config.json`` if present,
185+
otherwise``$HOME/.dockercfg``)
186+
187+
Returns:
188+
None
189+
"""
190+
self._auth_configs = auth.load_config(dockercfg_path)

0 commit comments

Comments
 (0)