Sha256: ba69487692904ab903a5c85d907d96382fa9fed46c7791b632c1597af12fd690

Contents?: true

Size: 1.07 KB

Versions: 7

Compression:

Stored size: 1.07 KB

Contents

module Percheron
  module Actions
    class Recreate

      include Base

      def initialize(container, start: false)
        @container = container
        @start = start
      end

      def execute!
        results = []
        if recreate?
          results << recreate!
          results << start!
        else
          inform!
        end
        results.compact.empty? ? nil : container
      end

      private

        attr_reader :container, :start
        alias_method :start?, :start

        def recreate?
          !container.versions_match? || !container.dockerfile_md5s_match?
        end

        def inform!
          return nil unless container.dockerfile_md5s_match?
          $logger.info "Container '#{container.name}' - No Dockerfile changes or version bump"
        end

        def recreate!
          $logger.debug "Container '#{container.name}' exists but will be recreated"
          Purge.new(container).execute!
          Create.new(container).execute!
        end

        def start!
          Start.new(container).execute! if start?
        end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
percheron-0.7.6 lib/percheron/actions/recreate.rb
percheron-0.7.5 lib/percheron/actions/recreate.rb
percheron-0.7.4 lib/percheron/actions/recreate.rb
percheron-0.7.3 lib/percheron/actions/recreate.rb
percheron-0.7.2 lib/percheron/actions/recreate.rb
percheron-0.7.1 lib/percheron/actions/recreate.rb
percheron-0.7.0 lib/percheron/actions/recreate.rb