Sha256: 572be9b9111143ee633db2f7bce43444a99c1601da644ea82270121af84d03e8

Contents?: true

Size: 1 KB

Versions: 6

Compression:

Stored size: 1 KB

Contents

module Percheron
  module Actions
    class Recreate

      include Base

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

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

      private

        attr_reader :unit, :start
        alias_method :start?, :start

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

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

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

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

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
percheron-0.7.13 lib/percheron/actions/recreate.rb
percheron-0.7.12 lib/percheron/actions/recreate.rb
percheron-0.7.11 lib/percheron/actions/recreate.rb
percheron-0.7.10 lib/percheron/actions/recreate.rb
percheron-0.7.9 lib/percheron/actions/recreate.rb
percheron-0.7.8 lib/percheron/actions/recreate.rb