Sha256: 7c5f0dfbb60787ed026236dab251811d3ea87e706600560fe4ec38b2484ea358

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

module EbDeployer
  module DeploymentStrategy
    class BlueOnly
      def initialize(component)
        @component = component
      end

      def test_compatibility(env_create_options)
        tier = env_create_options[:tier]
        if tier && tier.downcase == 'worker'
          raise "Blue only deployment is not supported for Worker tier"
        end
      end

      def deploy(version_label, env_settings, inactive_settings=[])
        if !ebenvs.any?(&method(:active_ebenv?))
          ebenv('a', @component.cname_prefix).
            deploy(version_label, env_settings)
          return
        end

        inactive_ebenv = ebenvs.reject(&method(:active_ebenv?)).first

        inactive_ebenv.deploy(version_label, env_settings)
      end

      private
      def active_ebenv?(ebenv)
        ebenv.cname_prefix == @component.cname_prefix
      end

      def ebenvs
        [ebenv('a'), ebenv('b')]
      end

      def ebenv(suffix, cname_prefix=nil)
        @component.new_eb_env(suffix, cname_prefix || inactive_cname_prefix)
      end

      def inactive_cname_prefix
        "#{@component.cname_prefix}-inactive"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 3 rubygems

Version Path
man_eb_deployer-0.8.0 lib/eb_deployer/deployment_strategy/blue_only.rb
eb_deployer_updated-0.8.1 lib/eb_deployer/deployment_strategy/blue_only.rb
eb_deployer_updated-0.8.0 lib/eb_deployer/deployment_strategy/blue_only.rb
eb_deployer-0.7.0 lib/eb_deployer/deployment_strategy/blue_only.rb