Skip to content

Commit 0031ac2

Browse files
authored
api: add force to plugin disable (#2843)
Signed-off-by: till <till@php.net>
1 parent b2a18d7 commit 0031ac2

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

docker/api/plugin.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,20 @@ def create_plugin(self, name, plugin_data_dir, gzip=False):
5151
return True
5252

5353
@utils.minimum_version('1.25')
54-
def disable_plugin(self, name):
54+
def disable_plugin(self, name, force=False):
5555
"""
5656
Disable an installed plugin.
5757
5858
Args:
5959
name (string): The name of the plugin. The ``:latest`` tag is
6060
optional, and is the default if omitted.
61+
force (bool): To enable the force query parameter.
6162
6263
Returns:
6364
``True`` if successful
6465
"""
6566
url = self._url('/plugins/{0}/disable', name)
66-
res = self._post(url)
67+
res = self._post(url, params={'force': force})
6768
self._raise_for_status(res)
6869
return True
6970

docker/models/plugins.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,19 @@ def configure(self, options):
4444
self.client.api.configure_plugin(self.name, options)
4545
self.reload()
4646

47-
def disable(self):
47+
def disable(self, force=False):
4848
"""
4949
Disable the plugin.
5050
51+
Args:
52+
force (bool): Force disable. Default: False
53+
5154
Raises:
5255
:py:class:`docker.errors.APIError`
5356
If the server returns an error.
5457
"""
5558

56-
self.client.api.disable_plugin(self.name)
59+
self.client.api.disable_plugin(self.name, force)
5760
self.reload()
5861

5962
def enable(self, timeout=0):

tests/integration/api_plugin_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ def teardown_class(cls):
2222
def teardown_method(self, method):
2323
client = self.get_client_instance()
2424
try:
25-
client.disable_plugin(SSHFS)
25+
client.disable_plugin(SSHFS, True)
2626
except docker.errors.APIError:
2727
pass
2828

2929
for p in self.tmp_plugins:
3030
try:
31-
client.remove_plugin(p, force=True)
31+
client.remove_plugin(p)
3232
except docker.errors.APIError:
3333
pass
3434

0 commit comments

Comments
 (0)