mirror of https://github.com/docker/docker-py.git
api: add force to plugin disable (#2843)
Signed-off-by: till <till@php.net>
This commit is contained in:
parent
b2a18d7209
commit
0031ac2186
|
@ -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
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue