Sha256: b87ff9b9f813c70b92eadd1708f2eaa25ea11ee6e6c0021bf93bbc521ed73926

Contents?: true

Size: 949 Bytes

Versions: 6

Compression:

Stored size: 949 Bytes

Contents

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

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

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

        inactive_ebenv.deploy(version_label, env_settings)
      end

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

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

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

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
eb_deployer-0.4.13 lib/eb_deployer/deployment_strategy/blue_only.rb
eb_deployer-0.4.12 lib/eb_deployer/deployment_strategy/blue_only.rb
eb_deployer-0.4.11 lib/eb_deployer/deployment_strategy/blue_only.rb
eb_deployer-0.4.10 lib/eb_deployer/deployment_strategy/blue_only.rb
eb_deployer-0.4.9 lib/eb_deployer/deployment_strategy/blue_only.rb
eb_deployer-0.4.8 lib/eb_deployer/deployment_strategy/blue_only.rb