diff options
author | Till! <till@users.noreply.github.com> | 2022-07-29 20:51:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-29 14:51:43 -0400 |
commit | 0031ac2186406c9b48c6fc5253affd4b62fef0f5 (patch) | |
tree | 227348fcfe30f474895e569100474eab24a42825 | |
parent | b2a18d7209f827d83cc33acb80aa31bf404ffd4b (diff) | |
download | docker-py-0031ac2186406c9b48c6fc5253affd4b62fef0f5.tar.gz |
api: add force to plugin disable (#2843)
Signed-off-by: till <till@php.net>
-rw-r--r-- | docker/api/plugin.py | 5 | ||||
-rw-r--r-- | docker/models/plugins.py | 7 | ||||
-rw-r--r-- | tests/integration/api_plugin_test.py | 4 |
3 files changed, 10 insertions, 6 deletions
diff --git a/docker/api/plugin.py b/docker/api/plugin.py index 57110f1..10210c1 100644 --- a/docker/api/plugin.py +++ b/docker/api/plugin.py @@ -51,19 +51,20 @@ class PluginApiMixin: return True @utils.minimum_version('1.25') - def disable_plugin(self, name): + def disable_plugin(self, name, force=False): """ Disable an installed plugin. Args: name (string): The name of the plugin. The ``:latest`` tag is optional, and is the default if omitted. + force (bool): To enable the force query parameter. Returns: ``True`` if successful """ url = self._url('/plugins/{0}/disable', name) - res = self._post(url) + res = self._post(url, params={'force': force}) self._raise_for_status(res) return True diff --git a/docker/models/plugins.py b/docker/models/plugins.py index 69b94f3..16f5245 100644 --- a/docker/models/plugins.py +++ b/docker/models/plugins.py @@ -44,16 +44,19 @@ class Plugin(Model): self.client.api.configure_plugin(self.name, options) self.reload() - def disable(self): + def disable(self, force=False): """ Disable the plugin. + Args: + force (bool): Force disable. Default: False + Raises: :py:class:`docker.errors.APIError` If the server returns an error. """ - self.client.api.disable_plugin(self.name) + self.client.api.disable_plugin(self.name, force) self.reload() def enable(self, timeout=0): diff --git a/tests/integration/api_plugin_test.py b/tests/integration/api_plugin_test.py index 38f9d12..3ecb028 100644 --- a/tests/integration/api_plugin_test.py +++ b/tests/integration/api_plugin_test.py @@ -22,13 +22,13 @@ class PluginTest(BaseAPIIntegrationTest): def teardown_method(self, method): client = self.get_client_instance() try: - client.disable_plugin(SSHFS) + client.disable_plugin(SSHFS, True) except docker.errors.APIError: pass for p in self.tmp_plugins: try: - client.remove_plugin(p, force=True) + client.remove_plugin(p) except docker.errors.APIError: pass |