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
# 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
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



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

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

#cname_prefixObject



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

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

#deploy(version_label, settings) ⇒ Object



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

def deploy(version_label, settings)
  terminate if @creation_opts[:phoenix_mode]
  create_or_update_env(version_label, settings)
  smoke_test
  wait_for_env_become_healthy
end

#log(msg) ⇒ Object



38
39
40
# File 'lib/eb_deployer/environment.rb', line 38

def log(msg)
  puts "[#{Time.now.utc}][beanstalk:#{@name}] #{msg}"
end

#swap_cname_with(another) ⇒ Object



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

def swap_cname_with(another)
  log("Swap CNAME with env #{another.name}")
  @bs.environment_swap_cname(self.app, self.name, another.name)
end