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