eb_deployer 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ 0.4.2
2
+ =====
3
+ * Allow provding different deploy strategy for different components.
4
+
1
5
  0.4.1
2
6
  =====
3
7
  * Remove options for delete all environments ("-d --all"), because it is too destructive and not recoverable.
@@ -2,21 +2,21 @@ module EbDeployer
2
2
  class Component
3
3
  attr_reader :name
4
4
 
5
- def initialize(name, env, creation_opts, eb_settings, eb_driver)
5
+ def initialize(name, env, creation_opts, eb_settings, strategy_name, eb_driver)
6
6
  @name = name
7
7
  @env = env
8
8
  @eb_driver = eb_driver
9
9
  @creation_opts = creation_opts
10
10
  @eb_settings = eb_settings
11
+ @strategy = DeploymentStrategy.create(self, strategy_name)
11
12
  end
12
13
 
13
14
  def cname_prefix
14
15
  @creation_opts[:cname_prefix] || default_cname_prefix
15
16
  end
16
17
 
17
- def deploy(version_label, strategy_name, eb_settings)
18
- strategy = create_strategy(strategy_name)
19
- strategy.deploy(version_label, eb_settings + @eb_settings)
18
+ def deploy(version_label, eb_settings)
19
+ @strategy.deploy(version_label, eb_settings + @eb_settings)
20
20
  end
21
21
 
22
22
  def new_eb_env(suffix=nil, cname_prefix_overriding=nil)
@@ -31,10 +31,5 @@ module EbDeployer
31
31
  def default_cname_prefix
32
32
  [@env.app_name, @env.name, @name].join('-')
33
33
  end
34
-
35
- def create_strategy(strategy_name)
36
- DeploymentStrategy.create(self, strategy_name)
37
- end
38
-
39
34
  end
40
35
  end
@@ -1,9 +1,10 @@
1
1
  module EbDeployer
2
2
  class DefaultComponent
3
- def initialize(env, creation_opts, eb_driver)
3
+ def initialize(env, creation_opts, strategy_name, eb_driver)
4
4
  @env = env
5
5
  @eb_driver = eb_driver
6
6
  @creation_opts = creation_opts
7
+ @strategy = DeploymentStrategy.create(self, strategy_name)
7
8
  end
8
9
 
9
10
  def cname_prefix
@@ -11,9 +12,8 @@ module EbDeployer
11
12
  end
12
13
 
13
14
 
14
- def deploy(version_label, strategy_name, eb_settings)
15
- strategy = create_strategy(strategy_name)
16
- strategy.deploy(version_label, eb_settings)
15
+ def deploy(version_label, eb_settings)
16
+ @strategy.deploy(version_label, eb_settings)
17
17
  end
18
18
 
19
19
  def new_eb_env(suffix=nil, cname_prefix_overriding=nil)
@@ -28,10 +28,5 @@ module EbDeployer
28
28
  def default_cname_prefix
29
29
  [@env.app_name, @env.name].join('-')
30
30
  end
31
-
32
- def create_strategy(strategy_name)
33
- DeploymentStrategy.create(self, strategy_name)
34
- end
35
-
36
31
  end
37
32
  end
@@ -1,6 +1,6 @@
1
1
  module EbDeployer
2
2
  class Environment
3
- attr_writer :resource_stacks, :settings, :creation_opts, :components, :component_under_deploy
3
+ attr_writer :resource_stacks, :settings, :creation_opts, :components, :component_under_deploy, :strategy_name
4
4
  attr_reader :name
5
5
 
6
6
  def initialize(app, name, eb_driver, &block)
@@ -9,9 +9,10 @@ module EbDeployer
9
9
  @eb_driver = eb_driver
10
10
  @creation_opts = {}
11
11
  @settings = []
12
+ @strategy_name = :blue_green
12
13
  yield(self) if block_given?
13
14
  unless @components
14
- @components = [DefaultComponent.new(self, @creation_opts, @eb_driver)]
15
+ @components = [DefaultComponent.new(self, @creation_opts, @strategy_name, @eb_driver)]
15
16
  end
16
17
  end
17
18
 
@@ -19,10 +20,10 @@ module EbDeployer
19
20
  @app.name
20
21
  end
21
22
 
22
- def deploy(version_label, strategy_name)
23
+ def deploy(version_label)
23
24
  resource_settings = @resource_stacks.provision(resource_stack_name)
24
25
  components_to_deploy.each do |component|
25
- component.deploy(version_label, strategy_name, @settings + resource_settings)
26
+ component.deploy(version_label, @settings + resource_settings)
26
27
  end
27
28
  end
28
29
 
@@ -32,7 +33,8 @@ module EbDeployer
32
33
  attrs = symbolize_keys(attrs)
33
34
  name = attrs.delete(:name)
34
35
  eb_settings = attrs.delete(:option_settings) || []
35
- Component.new(name, self, @creation_opts.merge(attrs), eb_settings, @eb_driver)
36
+ strategy_name = attrs[:strategy] || @strategy_name
37
+ Component.new(name, self, @creation_opts.merge(attrs), eb_settings, strategy_name, @eb_driver)
36
38
  end
37
39
  end
38
40
 
@@ -1,3 +1,3 @@
1
1
  module EbDeployer
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
data/lib/eb_deployer.rb CHANGED
@@ -181,7 +181,6 @@ module EbDeployer
181
181
  version_label = "#{version_prefix}#{opts[:version_label].to_s.strip}"
182
182
  cname = opts[:cname]
183
183
  eb_settings = opts[:option_settings] || opts[:settings] || []
184
- strategy_name = opts[:strategy] || :blue_green
185
184
  cname_prefix = opts[:cname_prefix]
186
185
  smoke_test = opts[:smoke_test] || Proc.new {}
187
186
  phoenix_mode = opts[:phoenix_mode]
@@ -202,13 +201,13 @@ module EbDeployer
202
201
  :phoenix_mode => phoenix_mode,
203
202
  :tier => app_tier
204
203
  }
205
-
204
+ env.strategy_name = opts[:strategy] || :blue_green
206
205
  env.components = opts[:components]
207
206
  env.component_under_deploy = opts[:component]
208
207
  end
209
208
 
210
209
  application.create_version(version_label, opts[:package])
211
- environment.deploy(version_label, strategy_name)
210
+ environment.deploy(version_label)
212
211
  application.clean_versions(version_prefix, keep_latest)
213
212
  end
214
213
 
@@ -63,6 +63,16 @@ class MultiComponentsDeployTest < DeployTest
63
63
  assert_equal [minsize_3, minsize_2], @eb.environment_settings('simple', t('prod-api', 'simple'))
64
64
  end
65
65
 
66
+ def test_override_deployment_strategy
67
+ do_deploy(:components => [{'name' => 'web',
68
+ 'strategy' => 'blue-green' },
69
+ {'name' => 'bg',
70
+ 'strategy' => 'inplace-update'}])
71
+
72
+ assert @eb.environment_exists?('simple', t('prod-web-a', 'simple'))
73
+ assert @eb.environment_exists?('simple', t('prod-bg', 'simple'))
74
+ end
75
+
66
76
  def test_can_deploy_single_component
67
77
  do_deploy(:component => "bg")
68
78
  assert !@eb.environment_exists?('simple', t('prod-web', 'simple'))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eb_deployer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-03-31 00:00:00.000000000 Z
13
+ date: 2014-04-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: aws-sdk
@@ -99,7 +99,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
99
  version: '0'
100
100
  segments:
101
101
  - 0
102
- hash: -3040208226803688120
102
+ hash: -3697140249092762497
103
103
  required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  none: false
105
105
  requirements:
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  version: '0'
109
109
  segments:
110
110
  - 0
111
- hash: -3040208226803688120
111
+ hash: -3697140249092762497
112
112
  requirements: []
113
113
  rubyforge_project:
114
114
  rubygems_version: 1.8.29