Sha256: e80d06064a72bedf675588a33247cc299baaf41e7900f71664e11ce311483866

Contents?: true

Size: 816 Bytes

Versions: 1

Compression:

Stored size: 816 Bytes

Contents

module Percheron
  module Actions
    class Purge

      include Base

      def initialize(container)
        @container = container
      end

      def execute!
        results = []
        results << stop!
        results << delete_container! if container.exists?
        results << delete_image!     if container.image_exists?
        results.compact.empty? ? nil : 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

1 entries across 1 versions & 1 rubygems

Version Path
percheron-0.6.4 lib/percheron/actions/purge.rb