engineyard 1.3.31 → 1.3.32

Sign up to get free protection for your applications and to get access to all the features.
@@ -63,9 +63,12 @@ module EY
63
63
  EY.ui.info "Beginning deploy for '#{app.name}' in '#{environment.name}' on server..."
64
64
 
65
65
  deploy_options = {'extras' => options[:extra_deploy_hook_options]}
66
- deploy_options['migrate'] = options['migrate'] if options.has_key?('migrate')
66
+ if options.has_key?('migrate') # thor set migrate => nil when --no-migrate
67
+ deploy_options['migrate'] = options['migrate'].respond_to?(:to_str) ? options['migrate'] : !!options['migrate']
68
+ end
67
69
  deploy_options['verbose'] = options['verbose'] if options.has_key?('verbose')
68
70
 
71
+
69
72
  if environment.deploy(app, deploy_ref, deploy_options)
70
73
  EY.ui.info "Deploy complete"
71
74
  EY.ui.info "Now you can run `ey launch' to open the application in a browser."
@@ -1,6 +1,8 @@
1
1
  module EY
2
2
  module Model
3
- class Environment < ApiStruct.new(:id, :account, :name, :framework_env, :instances, :instances_count, :apps, :app_master, :username, :app_server_stack_name, :load_balancer_ip_address, :api)
3
+ class Environment < ApiStruct.new(:id, :account, :name, :framework_env, :instances, :instances_count,
4
+ :apps, :app_master, :username, :app_server_stack_name, :deployment_configurations,
5
+ :load_balancer_ip_address, :api)
4
6
  require 'launchy'
5
7
 
6
8
  attr_accessor :ignore_bad_master
@@ -36,7 +38,7 @@ module EY
36
38
  def deploy(app, ref, deploy_options={})
37
39
  app_master!.deploy(app,
38
40
  ref,
39
- migration_command(deploy_options),
41
+ migration_command(app, deploy_options),
40
42
  config.merge(deploy_options['extras']),
41
43
  deploy_options['verbose'])
42
44
  end
@@ -137,49 +139,48 @@ module EY
137
139
  Launchy.open(app_master!.hostname_url)
138
140
  end
139
141
 
140
- private
141
-
142
- def migration_command(deploy_options)
142
+ def migration_command(app, deploy_options)
143
143
  # regarding deploy_options['migrate']:
144
144
  #
145
145
  # missing means migrate how the yaml file says to
146
146
  # nil means don't migrate
147
147
  # true means migrate w/custom command (if present) or default
148
148
  # a string means migrate with this specific command
149
- if deploy_options.has_key?('migrate')
150
- migration_command_from_command_line(deploy_options)
151
- else
152
- migration_command_from_config
149
+ return nil if no_migrate?(deploy_options)
150
+ command = migration_command_from_command_line(deploy_options)
151
+ unless command
152
+ return nil if no_migrate?(config)
153
+ command = migration_command_from_config
153
154
  end
155
+ command = migration_command_from_environment(app) unless command
156
+ command
157
+ end
158
+
159
+ private
160
+
161
+ def no_migrate?(hash)
162
+ hash.key?('migrate') && hash['migrate'] == false
154
163
  end
155
164
 
156
165
  def migration_command_from_config
157
- if config.has_key?('migrate')
158
- if config['migrate']
159
- default_migration_command
160
- else
161
- nil
162
- end
163
- else
164
- default_migration_command
165
- end
166
+ config['migration_command'] if config['migrate'] || config['migration_command']
166
167
  end
167
168
 
168
169
  def migration_command_from_command_line(deploy_options)
169
- if deploy_options['migrate'].nil?
170
- nil
171
- elsif deploy_options['migrate'].respond_to?(:to_str)
172
- deploy_options['migrate'].to_str
173
- else
174
- default_migration_command
170
+ if migrate = deploy_options['migrate']
171
+ migrate.respond_to?(:to_str) ? migrate.to_str : (config['migration_command'] || default_migration_command)
175
172
  end
176
173
  end
177
174
 
175
+ def migration_command_from_environment(app)
176
+ if deploy_config = deployment_configurations[app.name]
177
+ deploy_config['migrate']['command'] if deploy_config['migrate']['perform']
178
+ end
179
+ end
178
180
 
179
181
  def default_migration_command
180
- config['migration_command'] || 'rake db:migrate --trace'
182
+ 'rake db:migrate'
181
183
  end
182
-
183
184
  end
184
185
  end
185
186
  end
@@ -1,3 +1,3 @@
1
1
  module EY
2
- VERSION = '1.3.31'
2
+ VERSION = '1.3.32'
3
3
  end
@@ -153,3 +153,52 @@ describe "EY::Model::Environment#shorten_name_for(app)" do
153
153
  short('dev', 'dev').should == 'dev'
154
154
  end
155
155
  end
156
+
157
+ describe "EY::Model::Environment#migration_command" do
158
+ before do
159
+ @app = EY::Model::App.from_hash({:name => 'fake'})
160
+ @migrate = EY::Model::Environment.from_hash({
161
+ "id" => 10291,
162
+ "api" => @api,
163
+ 'name' => 'migrate',
164
+ 'deployment_configurations' => {'fake' => {'migrate' => {'command' => 'fake db:migrate', 'perform' => true}}}
165
+ })
166
+
167
+ @no_migrate = EY::Model::Environment.from_hash({
168
+ "id" => 10291,
169
+ "api" => @api,
170
+ 'name' => 'no_migrate',
171
+ 'deployment_configurations' => {'fake' => {'migrate' => {'command' => 'fake db:migrate', 'perform' => false}}}
172
+ })
173
+ end
174
+
175
+ it "returns the migration command for the environment when the perform flag is true" do
176
+ @migrate.migration_command(@app, {}).should == 'fake db:migrate'
177
+ end
178
+
179
+ it "returns nil when the perform flag in the environment is false" do
180
+ @no_migrate.migration_command(@app, {}).should == nil
181
+ end
182
+
183
+ context "with the migrate deploy option" do
184
+ it "returns the default migration command when is true" do
185
+ @migrate.migration_command(@app, {'migrate' => true}).should == 'rake db:migrate'
186
+ end
187
+
188
+ it "return the custom migration command when is a string" do
189
+ @migrate.migration_command(@app, {'migrate' => 'foo migrate'}).should == 'foo migrate'
190
+ end
191
+ end
192
+
193
+ context "with the migrate option in the global configuration" do
194
+ it "return the default migration command when the option is true" do
195
+ EY.config.environments['migrate'] = {'migrate' => true, 'migration_command' => 'bar migrate'}
196
+ @migrate.migration_command(@app, {}).should == 'bar migrate'
197
+ end
198
+
199
+ it "return the custom migration command when the option is a string" do
200
+ EY.config.environments['migrate'] = {'migration_command' => 'bar migrate'}
201
+ @migrate.migration_command(@app, {}).should == 'bar migrate'
202
+ end
203
+ end
204
+ end
@@ -108,7 +108,7 @@ describe "ey deploy" do
108
108
  it "defaults to 'rake db:migrate'" do
109
109
  fast_ey %w[deploy]
110
110
  @ssh_commands.last.should =~ /engineyard-serverside.*deploy/
111
- @ssh_commands.last.should =~ /--migrate 'rake db:migrate --trace'/
111
+ @ssh_commands.last.should =~ /--migrate 'rake db:migrate'/
112
112
  end
113
113
 
114
114
  it "can be disabled with --no-migrate" do
@@ -119,7 +119,7 @@ describe "ey deploy" do
119
119
 
120
120
  it "uses the default when --migrate is specified with no value" do
121
121
  fast_ey %w[deploy --migrate]
122
- @ssh_commands.last.should match(/--migrate 'rake db:migrate --trace'/)
122
+ @ssh_commands.last.should match(/--migrate 'rake db:migrate'/)
123
123
  end
124
124
 
125
125
  context "customized in ey.yml" do
@@ -151,7 +151,7 @@ describe "ey deploy" do
151
151
 
152
152
  it "migrates with the default when --migrate is specified with no value" do
153
153
  fast_ey %w[deploy --migrate]
154
- @ssh_commands.last.should match(/--migrate 'rake db:migrate --trace'/)
154
+ @ssh_commands.last.should match(/--migrate 'rake db:migrate'/)
155
155
  end
156
156
  end
157
157
 
@@ -161,7 +161,7 @@ describe "ey deploy" do
161
161
 
162
162
  it "migrates with the default" do
163
163
  fast_ey %w[deploy]
164
- @ssh_commands.last.should match(/--migrate 'rake db:migrate --trace'/)
164
+ @ssh_commands.last.should match(/--migrate 'rake db:migrate'/)
165
165
  end
166
166
  end
167
167
 
@@ -84,6 +84,11 @@ module Scenario
84
84
  "instances_count" => 4,
85
85
  "app_server_stack_name" => "nginx_mongrel",
86
86
  "load_balancer_ip_address" => '127.0.0.0',
87
+ "deployment_configurations" => {
88
+ "rails232app" => {
89
+ 'migrate' => {'command' => 'rake db:migrate', 'perform' => true}
90
+ }
91
+ },
87
92
  "framework_env" => "production"}]
88
93
  end
89
94
 
@@ -165,6 +170,11 @@ module Scenario
165
170
  "id" => 200,
166
171
  "app_server_stack_name" => "nginx_mongrel",
167
172
  "load_balancer_ip_address" => '127.0.0.0',
173
+ "deployment_configurations" => {
174
+ "rails232app" => {
175
+ 'migrate' => {'command' => 'rake db:migrate', 'perform' => true}
176
+ }
177
+ },
168
178
  "framework_env" => "production"}]
169
179
  end
170
180
 
@@ -211,6 +221,11 @@ module Scenario
211
221
  "app_server_stack_name" => "nginx_mongrel",
212
222
  "load_balancer_ip_address" => '127.0.0.0',
213
223
  "framework_env" => "production",
224
+ "deployment_configurations" => {
225
+ "rails232app" => {
226
+ 'migrate' => {'command' => 'rake db:migrate', 'perform' => true}
227
+ }
228
+ },
214
229
  }, {
215
230
  "ssh_username" => "ham",
216
231
  "instances" => [],
@@ -219,6 +234,11 @@ module Scenario
219
234
  "app_server_stack_name" => "nginx_passenger",
220
235
  "load_balancer_ip_address" => '127.0.0.0',
221
236
  "id" => 202,
237
+ "deployment_configurations" => {
238
+ "rails232app" => {
239
+ 'migrate' => {'command' => 'rake db:migrate', 'perform' => true}
240
+ }
241
+ },
222
242
  }, {
223
243
  "ssh_username" => "hamburger",
224
244
  "instances" => [],
@@ -284,6 +304,11 @@ module Scenario
284
304
  "instances" => [railsapp_master],
285
305
  "app_server_stack_name" => "nginx_unicorn",
286
306
  "load_balancer_ip_address" => '127.0.0.0',
307
+ "deployment_configurations" => {
308
+ "rails232app" => {
309
+ 'migrate' => {'command' => 'rake db:migrate', 'perform' => true}
310
+ }
311
+ },
287
312
  }, {
288
313
  "id" => 439,
289
314
  "framework_env" => "production",
@@ -293,6 +318,11 @@ module Scenario
293
318
  "load_balancer_ip_address" => '127.0.0.0',
294
319
  "app_server_stack_name" => "nginx_mongrel",
295
320
  "instances" => [keycollector_master],
321
+ "deployment_configurations" => {
322
+ "keycollector" => {
323
+ 'migrate' => {'command' => 'rake db:migrate', 'perform' => true}
324
+ }
325
+ },
296
326
  }]
297
327
  end
298
328
  end # TwoApps
@@ -330,6 +360,11 @@ module Scenario
330
360
  "load_balancer_ip_address" => '127.0.0.0',
331
361
  "app_server_stack_name" => "nginx_mongrel",
332
362
  "framework_env" => "production",
363
+ "deployment_configurations" => {
364
+ "rails232app" => {
365
+ 'migrate' => {'command' => 'rake db:migrate', 'perform' => true}
366
+ }
367
+ },
333
368
  }, {
334
369
  "id" => 202,
335
370
  "ssh_username" => "ham",
@@ -344,6 +379,11 @@ module Scenario
344
379
  "load_balancer_ip_address" => '127.3.2.1',
345
380
  "app_server_stack_name" => "nginx_passenger",
346
381
  "framework_env" => "production",
382
+ "deployment_configurations" => {
383
+ "rails232app" => {
384
+ 'migrate' => {'command' => 'rake db:migrate', 'perform' => true}
385
+ }
386
+ },
347
387
  }, {
348
388
  "ssh_username" => "ham",
349
389
  "instances" => [{
@@ -358,6 +398,11 @@ module Scenario
358
398
  "id" => 204,
359
399
  "load_balancer_ip_address" => '127.0.0.2',
360
400
  "framework_env" => "production",
401
+ "deployment_configurations" => {
402
+ "rails232app" => {
403
+ 'migrate' => {'command' => 'rake db:migrate', 'perform' => true}
404
+ }
405
+ },
361
406
  }]
362
407
  end
363
408
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: engineyard
3
3
  version: !ruby/object:Gem::Version
4
- hash: 37
4
+ hash: 91
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 3
9
- - 31
10
- version: 1.3.31
9
+ - 32
10
+ version: 1.3.32
11
11
  platform: ruby
12
12
  authors:
13
13
  - EY Cloud Team
@@ -15,13 +15,9 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-21 00:00:00 -07:00
19
- default_executable: ey
18
+ date: 2011-09-23 00:00:00 Z
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
- prerelease: false
23
- type: :runtime
24
- name: thor
25
21
  version_requirements: &id001 !ruby/object:Gem::Requirement
26
22
  none: false
27
23
  requirements:
@@ -33,11 +29,11 @@ dependencies:
33
29
  - 14
34
30
  - 6
35
31
  version: 0.14.6
32
+ name: thor
33
+ type: :runtime
34
+ prerelease: false
36
35
  requirement: *id001
37
36
  - !ruby/object:Gem::Dependency
38
- prerelease: false
39
- type: :runtime
40
- name: rest-client
41
37
  version_requirements: &id002 !ruby/object:Gem::Requirement
42
38
  none: false
43
39
  requirements:
@@ -49,11 +45,11 @@ dependencies:
49
45
  - 6
50
46
  - 0
51
47
  version: 1.6.0
48
+ name: rest-client
49
+ type: :runtime
50
+ prerelease: false
52
51
  requirement: *id002
53
52
  - !ruby/object:Gem::Dependency
54
- prerelease: false
55
- type: :runtime
56
- name: highline
57
53
  version_requirements: &id003 !ruby/object:Gem::Requirement
58
54
  none: false
59
55
  requirements:
@@ -65,11 +61,11 @@ dependencies:
65
61
  - 6
66
62
  - 1
67
63
  version: 1.6.1
64
+ name: highline
65
+ type: :runtime
66
+ prerelease: false
68
67
  requirement: *id003
69
68
  - !ruby/object:Gem::Dependency
70
- prerelease: false
71
- type: :runtime
72
- name: json_pure
73
69
  version_requirements: &id004 !ruby/object:Gem::Requirement
74
70
  none: false
75
71
  requirements:
@@ -79,11 +75,11 @@ dependencies:
79
75
  segments:
80
76
  - 0
81
77
  version: "0"
78
+ name: json_pure
79
+ type: :runtime
80
+ prerelease: false
82
81
  requirement: *id004
83
82
  - !ruby/object:Gem::Dependency
84
- prerelease: false
85
- type: :runtime
86
- name: escape
87
83
  version_requirements: &id005 !ruby/object:Gem::Requirement
88
84
  none: false
89
85
  requirements:
@@ -95,11 +91,11 @@ dependencies:
95
91
  - 0
96
92
  - 4
97
93
  version: 0.0.4
94
+ name: escape
95
+ type: :runtime
96
+ prerelease: false
98
97
  requirement: *id005
99
98
  - !ruby/object:Gem::Dependency
100
- prerelease: false
101
- type: :runtime
102
- name: engineyard-serverside-adapter
103
99
  version_requirements: &id006 !ruby/object:Gem::Requirement
104
100
  none: false
105
101
  requirements:
@@ -111,11 +107,11 @@ dependencies:
111
107
  - 4
112
108
  - 13
113
109
  version: 1.4.13
110
+ name: engineyard-serverside-adapter
111
+ type: :runtime
112
+ prerelease: false
114
113
  requirement: *id006
115
114
  - !ruby/object:Gem::Dependency
116
- prerelease: false
117
- type: :runtime
118
- name: net-ssh
119
115
  version_requirements: &id007 !ruby/object:Gem::Requirement
120
116
  none: false
121
117
  requirements:
@@ -127,11 +123,11 @@ dependencies:
127
123
  - 1
128
124
  - 0
129
125
  version: 2.1.0
126
+ name: net-ssh
127
+ type: :runtime
128
+ prerelease: false
130
129
  requirement: *id007
131
130
  - !ruby/object:Gem::Dependency
132
- prerelease: false
133
- type: :runtime
134
- name: launchy
135
131
  version_requirements: &id008 !ruby/object:Gem::Requirement
136
132
  none: false
137
133
  requirements:
@@ -143,11 +139,11 @@ dependencies:
143
139
  - 0
144
140
  - 5
145
141
  version: 2.0.5
142
+ name: launchy
143
+ type: :runtime
144
+ prerelease: false
146
145
  requirement: *id008
147
146
  - !ruby/object:Gem::Dependency
148
- prerelease: false
149
- type: :development
150
- name: rspec
151
147
  version_requirements: &id009 !ruby/object:Gem::Requirement
152
148
  none: false
153
149
  requirements:
@@ -159,11 +155,11 @@ dependencies:
159
155
  - 3
160
156
  - 0
161
157
  version: 1.3.0
158
+ name: rspec
159
+ type: :development
160
+ prerelease: false
162
161
  requirement: *id009
163
162
  - !ruby/object:Gem::Dependency
164
- prerelease: false
165
- type: :development
166
- name: rake
167
163
  version_requirements: &id010 !ruby/object:Gem::Requirement
168
164
  none: false
169
165
  requirements:
@@ -173,11 +169,11 @@ dependencies:
173
169
  segments:
174
170
  - 0
175
171
  version: "0"
172
+ name: rake
173
+ type: :development
174
+ prerelease: false
176
175
  requirement: *id010
177
176
  - !ruby/object:Gem::Dependency
178
- prerelease: false
179
- type: :development
180
- name: fakeweb
181
177
  version_requirements: &id011 !ruby/object:Gem::Requirement
182
178
  none: false
183
179
  requirements:
@@ -187,11 +183,11 @@ dependencies:
187
183
  segments:
188
184
  - 0
189
185
  version: "0"
186
+ name: fakeweb
187
+ type: :development
188
+ prerelease: false
190
189
  requirement: *id011
191
190
  - !ruby/object:Gem::Dependency
192
- prerelease: false
193
- type: :development
194
- name: fakeweb-matcher
195
191
  version_requirements: &id012 !ruby/object:Gem::Requirement
196
192
  none: false
197
193
  requirements:
@@ -201,11 +197,11 @@ dependencies:
201
197
  segments:
202
198
  - 0
203
199
  version: "0"
200
+ name: fakeweb-matcher
201
+ type: :development
202
+ prerelease: false
204
203
  requirement: *id012
205
204
  - !ruby/object:Gem::Dependency
206
- prerelease: false
207
- type: :development
208
- name: fakefs
209
205
  version_requirements: &id013 !ruby/object:Gem::Requirement
210
206
  none: false
211
207
  requirements:
@@ -215,11 +211,11 @@ dependencies:
215
211
  segments:
216
212
  - 0
217
213
  version: "0"
214
+ name: fakefs
215
+ type: :development
216
+ prerelease: false
218
217
  requirement: *id013
219
218
  - !ruby/object:Gem::Dependency
220
- prerelease: false
221
- type: :development
222
- name: sinatra
223
219
  version_requirements: &id014 !ruby/object:Gem::Requirement
224
220
  none: false
225
221
  requirements:
@@ -229,11 +225,11 @@ dependencies:
229
225
  segments:
230
226
  - 0
231
227
  version: "0"
228
+ name: sinatra
229
+ type: :development
230
+ prerelease: false
232
231
  requirement: *id014
233
232
  - !ruby/object:Gem::Dependency
234
- prerelease: false
235
- type: :development
236
- name: realweb
237
233
  version_requirements: &id015 !ruby/object:Gem::Requirement
238
234
  none: false
239
235
  requirements:
@@ -245,11 +241,11 @@ dependencies:
245
241
  - 1
246
242
  - 6
247
243
  version: 0.1.6
244
+ name: realweb
245
+ type: :development
246
+ prerelease: false
248
247
  requirement: *id015
249
248
  - !ruby/object:Gem::Dependency
250
- prerelease: false
251
- type: :development
252
- name: open4
253
249
  version_requirements: &id016 !ruby/object:Gem::Requirement
254
250
  none: false
255
251
  requirements:
@@ -261,6 +257,9 @@ dependencies:
261
257
  - 0
262
258
  - 1
263
259
  version: 1.0.1
260
+ name: open4
261
+ type: :development
262
+ prerelease: false
264
263
  requirement: *id016
265
264
  description: This gem allows you to deploy your rails application to the Engine Yard cloud directly from the command line.
266
265
  email: cloud@engineyard.com
@@ -335,7 +334,6 @@ files:
335
334
  - spec/support/ruby_ext.rb
336
335
  - spec/support/scenarios.rb
337
336
  - spec/support/shared_behavior.rb
338
- has_rdoc: true
339
337
  homepage: http://github.com/engineyard/engineyard
340
338
  licenses: []
341
339
 
@@ -377,7 +375,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
377
375
  requirements: []
378
376
 
379
377
  rubyforge_project:
380
- rubygems_version: 1.5.2
378
+ rubygems_version: 1.8.6
381
379
  signing_key:
382
380
  specification_version: 3
383
381
  summary: Command-line deployment for the Engine Yard cloud