Sha256: 7ab11a3800caea5e58446fded3cb83059bb9daa7594222aaf5fdf9c0946982dd

Contents?: true

Size: 1.63 KB

Versions: 24

Compression:

Stored size: 1.63 KB

Contents

module EbDeployer
  class Environment
    include Utils
    attr_accessor :creation_opts, :strategy_name

    attr_writer :resource_stacks, :settings, :inactive_settings, :components, :component_under_deploy

    attr_reader :name

    def initialize(app, name, stack_name, eb_driver, &block)
      @app = app
      @name = name
      @stack_name = stack_name
      @eb_driver = eb_driver
      @creation_opts = {}
      @settings = []
      @inactive_settings = []
      @strategy_name = :blue_green
      yield(self) if block_given?
      unless @components
        @components = [DefaultComponent.new(self, @creation_opts, @strategy_name, @eb_driver)]
      end
    end

    def app_name
      @app.name
    end

    def deploy(version_label)
      resource_settings = @resource_stacks.provision(@stack_name)
      components_to_deploy.each do |component|
        component.deploy(version_label, @settings + resource_settings, @inactive_settings)
      end
    end

    def components=(components_attrs)
      return unless components_attrs
      @components = components_attrs.map do |attrs|
        attrs = symbolize_keys(attrs)
        Component.new(attrs.delete(:name), self, attrs, @eb_driver)
      end
    end

    private
    def components_to_deploy
      if @component_under_deploy
        component = component_named(@component_under_deploy)
        raise "'#{@component_under_deploy}' is not in the configuration. Available components are #{@components.map(&:name) }" unless component
        [component]
      else
        @components
      end
    end

    def component_named(name)
      @components.detect { |c| c.name == name }
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
eb_deployer-0.6.6 lib/eb_deployer/environment.rb
eb_deployer-0.6.5 lib/eb_deployer/environment.rb
eb_deployer-0.6.4 lib/eb_deployer/environment.rb
eb_deployer-0.6.3 lib/eb_deployer/environment.rb
eb_deployer-0.6.2 lib/eb_deployer/environment.rb
eb_deployer-0.6.1 lib/eb_deployer/environment.rb
eb_deployer-0.6.0 lib/eb_deployer/environment.rb
eb_deployer-0.6.0.beta6 lib/eb_deployer/environment.rb
eb_deployer-0.6.0.beta5 lib/eb_deployer/environment.rb
eb_deployer-0.6.0.beta4 lib/eb_deployer/environment.rb
eb_deployer-0.6.0.beta3 lib/eb_deployer/environment.rb
eb_deployer-0.6.0.beta2 lib/eb_deployer/environment.rb
eb_deployer-0.5.2 lib/eb_deployer/environment.rb
eb_deployer-0.6.0.beta1 lib/eb_deployer/environment.rb
eb_deployer-0.5.1.beta3 lib/eb_deployer/environment.rb
eb_deployer-0.5.1.beta2 lib/eb_deployer/environment.rb
eb_deployer-0.5.1.beta1 lib/eb_deployer/environment.rb
eb_deployer-0.5.0 lib/eb_deployer/environment.rb
eb_deployer-0.4.13 lib/eb_deployer/environment.rb
eb_deployer-0.4.12 lib/eb_deployer/environment.rb