Remove requires confirmation
This commit is contained in:
@@ -153,13 +153,17 @@ class Mrsk::Cli::Accessory < Mrsk::Cli::Base
|
|||||||
option :confirmed, aliases: "-y", type: :boolean, default: false, desc: "Proceed without confirmation question"
|
option :confirmed, aliases: "-y", type: :boolean, default: false, desc: "Proceed without confirmation question"
|
||||||
def remove(name)
|
def remove(name)
|
||||||
if name == "all"
|
if name == "all"
|
||||||
MRSK.accessory_names.each { |accessory_name| remove(accessory_name) }
|
if options[:confirmed] || ask("This will remove all containers and images for all accessories. Are you sure?", limited_to: %w( y N ), default: "N") == "y"
|
||||||
|
MRSK.accessory_names.each { |accessory_name| remove(accessory_name) }
|
||||||
|
end
|
||||||
else
|
else
|
||||||
with_accessory(name) do
|
if options[:confirmed] || ask("This will remove all containers and images for #{name}. Are you sure?", limited_to: %w( y N ), default: "N") == "y"
|
||||||
stop(name)
|
with_accessory(name) do
|
||||||
remove_container(name)
|
stop(name)
|
||||||
remove_image(name)
|
remove_container(name)
|
||||||
remove_service_directory(name)
|
remove_image(name)
|
||||||
|
remove_service_directory(name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -31,6 +31,14 @@ class CliAccessoryTest < CliTestCase
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "remove with confirmation" do
|
||||||
|
run_command("remove", "mysql", "-y").tap do |output|
|
||||||
|
assert_match /docker container stop app-mysql/, output
|
||||||
|
assert_match /docker image prune -a -f --filter label=service=app-mysql/, output
|
||||||
|
assert_match /rm -rf app-mysql/, output
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def run_command(*command)
|
def run_command(*command)
|
||||||
stdouted { Mrsk::Cli::Accessory.start([*command, "-c", "test/fixtures/deploy_with_accessories.yml"]) }
|
stdouted { Mrsk::Cli::Accessory.start([*command, "-c", "test/fixtures/deploy_with_accessories.yml"]) }
|
||||||
|
|||||||
Reference in New Issue
Block a user