class Percheron::Actions::Purge
Attributes
force[R]
unit[R]
Public Class Methods
new(unit, force: false)
click to toggle source
# File lib/percheron/actions/purge.rb, line 6 def initialize(unit, force: false) @unit = unit @force = force end
Public Instance Methods
execute!()
click to toggle source
# File lib/percheron/actions/purge.rb, line 11 def execute! results = [] results << stop! results << delete_unit! if delete_unit? results << delete_image! if delete_image? results.compact.empty? ? nil : unit end
Private Instance Methods
delete!(type, value) { || ... }
click to toggle source
# File lib/percheron/actions/purge.rb, line 47 def delete!(type, value) $logger.info("Deleting '%s' %s" % [ value, type ]) yield rescue Docker::Error::ConflictError => e $logger.error("Unable to delete '%s' %s - %s" % [ value, type, e.inspect ]) end
delete_image!()
click to toggle source
# File lib/percheron/actions/purge.rb, line 43 def delete_image! delete!('image', unit.image_name) { unit.image.remove(opts) } end
delete_image?()
click to toggle source
# File lib/percheron/actions/purge.rb, line 31 def delete_image? unit.image_exists? && unit.buildable? end
delete_unit!()
click to toggle source
# File lib/percheron/actions/purge.rb, line 39 def delete_unit! delete!('unit', unit.display_name) { unit.container.remove(opts) } end
delete_unit?()
click to toggle source
# File lib/percheron/actions/purge.rb, line 27 def delete_unit? unit.exists? end
opts()
click to toggle source
# File lib/percheron/actions/purge.rb, line 35 def opts { force: force } end
stop!()
click to toggle source
# File lib/percheron/actions/purge.rb, line 23 def stop! Stop.new(unit).execute! end