Sha256: 31137159b84e869f2f92ceb250526fb8345636a193439d06011f2ca38e4a8713

Contents?: true

Size: 731 Bytes

Versions: 4

Compression:

Stored size: 731 Bytes

Contents

module Percheron
  module Actions
    class Purge

      include Base

      def initialize(container)
        @container = container
      end

      def execute!
        stop!
        delete_container! if container.exists?
        delete_image!     if container.image_exists?
        container
      end

      private

        attr_reader :container

        def stop!
          Stop.new(container).execute!
        end

        def delete_container!
          $logger.info "Deleting '#{container.name}' container"
          container.docker_container.remove
        end

        def delete_image!
          $logger.info "Deleting '#{container.image_name}' image"
          container.image.remove
        end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
percheron-0.6.3 lib/percheron/actions/purge.rb
percheron-0.6.2 lib/percheron/actions/purge.rb
percheron-0.6.1 lib/percheron/actions/purge.rb
percheron-0.6.0 lib/percheron/actions/purge.rb