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
|
return True
|
||||||
|
|
||||||
@utils.minimum_version('1.25')
|
@utils.minimum_version('1.25')
|
||||||
def disable_plugin(self, name):
|
def disable_plugin(self, name, force=False):
|
||||||
"""
|
"""
|
||||||
Disable an installed plugin.
|
Disable an installed plugin.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
name (string): The name of the plugin. The ``:latest`` tag is
|
name (string): The name of the plugin. The ``:latest`` tag is
|
||||||
optional, and is the default if omitted.
|
optional, and is the default if omitted.
|
||||||
|
force (bool): To enable the force query parameter.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
``True`` if successful
|
``True`` if successful
|
||||||
"""
|
"""
|
||||||
url = self._url('/plugins/{0}/disable', name)
|
url = self._url('/plugins/{0}/disable', name)
|
||||||
res = self._post(url)
|
res = self._post(url, params={'force': force})
|
||||||
self._raise_for_status(res)
|
self._raise_for_status(res)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
@ -44,16 +44,19 @@ class Plugin(Model):
|
||||||
self.client.api.configure_plugin(self.name, options)
|
self.client.api.configure_plugin(self.name, options)
|
||||||
self.reload()
|
self.reload()
|
||||||
|
|
||||||
def disable(self):
|
def disable(self, force=False):
|
||||||
"""
|
"""
|
||||||
Disable the plugin.
|
Disable the plugin.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
force (bool): Force disable. Default: False
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
:py:class:`docker.errors.APIError`
|
:py:class:`docker.errors.APIError`
|
||||||
If the server returns an error.
|
If the server returns an error.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
self.client.api.disable_plugin(self.name)
|
self.client.api.disable_plugin(self.name, force)
|
||||||
self.reload()
|
self.reload()
|
||||||
|
|
||||||
def enable(self, timeout=0):
|
def enable(self, timeout=0):
|
||||||
|
|
|
@ -22,13 +22,13 @@ class PluginTest(BaseAPIIntegrationTest):
|
||||||
def teardown_method(self, method):
|
def teardown_method(self, method):
|
||||||
client = self.get_client_instance()
|
client = self.get_client_instance()
|
||||||
try:
|
try:
|
||||||
client.disable_plugin(SSHFS)
|
client.disable_plugin(SSHFS, True)
|
||||||
except docker.errors.APIError:
|
except docker.errors.APIError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
for p in self.tmp_plugins:
|
for p in self.tmp_plugins:
|
||||||
try:
|
try:
|
||||||
client.remove_plugin(p, force=True)
|
client.remove_plugin(p)
|
||||||
except docker.errors.APIError:
|
except docker.errors.APIError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue