lib/percheron/actions/purge.rb in percheron-0.7.2 vs lib/percheron/actions/purge.rb in percheron-0.7.3
- old
+ new
@@ -2,13 +2,13 @@
module Actions
class Purge
include Base
- def initialize(container, delete_image: true)
+ def initialize(container, force: false)
@container = container
- @delete_image = delete_image
+ @force = force
end
def execute!
results = []
results << stop!
@@ -17,31 +17,31 @@
results.compact.empty? ? nil : container
end
private
- attr_reader :container, :delete_image
+ attr_reader :container, :force
def stop!
Stop.new(container).execute!
end
def delete_image?
- delete_image && container.image_exists? && container.buildable?
+ container.image_exists? && container.buildable?
end
def delete_container!
return nil unless container.exists?
$logger.info "Deleting '#{container.name}' container"
- container.docker_container.remove
+ container.docker_container.remove(force: force)
rescue Docker::Error::ConflictError => e
$logger.error "Unable to delete '%s' container - %s" % [ container.name, e.inspect ]
end
def delete_image!
return nil unless delete_image?
$logger.info "Deleting '#{container.image_name}' image"
- container.image.remove
+ container.image.remove(force: force)
rescue Docker::Error::ConflictError => e
$logger.error "Unable to delete '%s' image - %s" % [ container.image_name, e.inspect ]
end
end