Class: EbDeployer::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/eb_deployer/environment.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, env_name, eb_driver, creation_opts = {}) ⇒ Environment

Returns a new instance of Environment.



11
12
13
14
15
16
17
# File 'lib/eb_deployer/environment.rb', line 11

def initialize(app, env_name, eb_driver, creation_opts={})
  @app = app
  @name = self.class.unique_ebenv_name(app, env_name)
  @bs = eb_driver
  @creation_opts = creation_opts
  @poller = EventPoller.new(@app, @name, @bs)
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



3
4
5
# File 'lib/eb_deployer/environment.rb', line 3

def app
  @app
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/eb_deployer/environment.rb', line 3

def name
  @name
end

Class Method Details

.unique_ebenv_name(app_name, env_name) ⇒ Object



5
6
7
8
9
# File 'lib/eb_deployer/environment.rb', line 5

def self.unique_ebenv_name(app_name, env_name)
  raise "Environment name #{env_name} is too long, it must be under 15 chars" if env_name.size > 15
  digest = Digest::SHA1.hexdigest(app_name + '-' + env_name)[0..6]
  "#{env_name}-#{digest}"
end

Instance Method Details

#==(another) ⇒ Object



30
31
32
# File 'lib/eb_deployer/environment.rb', line 30

def ==(another)
  self.app == another.app && self.name == another.name
end

#cname_prefixObject



26
27
28
# File 'lib/eb_deployer/environment.rb', line 26

def cname_prefix
  @bs.environment_cname_prefix(@app, @name)
end

#deploy(version_label, settings) ⇒ Object



19
20
21
22
23
24
# File 'lib/eb_deployer/environment.rb', line 19

def deploy(version_label, settings)
  create_or_update_env(version_label, settings)
  poll_events
  smoke_test
  wait_for_env_become_healthy
end

#swap_cname_with(another) ⇒ Object



34
35
36
# File 'lib/eb_deployer/environment.rb', line 34

def swap_cname_with(another)
  @bs.environment_swap_cname(self.app, self.name, another.name)
end