mirror of
https://github.com/nvbn/thefuck.git
synced 2025-03-14 14:48:49 +00:00
add docker container removal
This commit is contained in:
parent
4c3a559124
commit
dac27923bd
15
tests/rules/test_docker_image_being_used_by_container.py
Normal file
15
tests/rules/test_docker_image_being_used_by_container.py
Normal file
@ -0,0 +1,15 @@
|
||||
from thefuck.rules.docker_image_being_used_by_container import match, get_new_command
|
||||
from thefuck.types import Command
|
||||
|
||||
|
||||
def test_match():
|
||||
err_response = """
|
||||
Error response from daemon: conflict: unable to delete cd809b04b6ff (cannot be forced) - image
|
||||
is being used by running container e5e2591040d1
|
||||
"""
|
||||
assert match(Command('docker image rm -f cd809b04b6ff', err_response))
|
||||
|
||||
|
||||
def test_get_new_command():
|
||||
assert get_new_command(Command('docker image rm -f cd809b04b6ff',
|
||||
'')) == 'docker container rm -f e5e2591040d1 && docker image rm -f cd809b04b6ff'
|
11
thefuck/rules/docker_image_being_used_by_container.py
Normal file
11
thefuck/rules/docker_image_being_used_by_container.py
Normal file
@ -0,0 +1,11 @@
|
||||
from thefuck.utils import for_app, replace_command
|
||||
|
||||
|
||||
@for_app('docker')
|
||||
def match(command):
|
||||
return 'image is being used by running container' in command.output
|
||||
|
||||
|
||||
def get_new_command(command):
|
||||
container_id = command.output.split(' ')[-1]
|
||||
return 'docker container rm -f {} && {}'.format(container_id, command.script)
|
Loading…
x
Reference in New Issue
Block a user