api: add force to plugin disable (#2843)

Signed-off-by: till <till@php.net>
This commit is contained in:
Till! 2022-07-29 20:51:43 +02:00 committed by GitHub
parent b2a18d7209
commit 0031ac2186
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 6 deletions

View File

@ -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

View File

@ -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):

View File

@ -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