Sha256: 0a715ad89996b3087db390d828f3bee6dc3d12eefaeb6ae9a2b0617d49d62f22

Contents?: true

Size: 1.66 KB

Versions: 11

Compression:

Stored size: 1.66 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, eb_driver, &block)
      @app = app
      @name = 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(resource_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

    def resource_stack_name
      "#{app_name}-#{@name}"
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
eb_deployer-0.4.7.beta1 lib/eb_deployer/environment.rb
eb_deployer-0.4.6 lib/eb_deployer/environment.rb
eb_deployer-0.4.5 lib/eb_deployer/environment.rb
eb_deployer-0.4.4 lib/eb_deployer/environment.rb
eb_deployer-0.4.4.beta7 lib/eb_deployer/environment.rb
eb_deployer-0.4.4.beta6 lib/eb_deployer/environment.rb
eb_deployer-0.4.4.beta5 lib/eb_deployer/environment.rb
eb_deployer-0.4.4.beta4 lib/eb_deployer/environment.rb
eb_deployer-0.4.4.beta3 lib/eb_deployer/environment.rb
eb_deployer-0.4.4.beta2 lib/eb_deployer/environment.rb
eb_deployer-0.4.4.beta1 lib/eb_deployer/environment.rb