engineyard 0.7.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/engineyard/cli.rb +7 -4
- data/lib/engineyard/error.rb +1 -1
- data/lib/engineyard/model/environment.rb +5 -2
- data/lib/engineyard/model/instance.rb +4 -2
- data/lib/engineyard/version.rb +1 -1
- data/spec/engineyard/model/environment_spec.rb +7 -0
- data/spec/ey/deploy_spec.rb +3 -3
- data/spec/support/fake_awsm.ru +14 -0
- data/spec/support/shared_behavior.rb +27 -19
- metadata +4 -4
data/lib/engineyard/cli.rb
CHANGED
@@ -23,14 +23,16 @@ module EY
|
|
23
23
|
This command must be run with the current directory containing the app to be
|
24
24
|
deployed. If ey.yml specifies a default branch then the ref parameter can be
|
25
25
|
omitted. Furthermore, if a default branch is specified but a different command
|
26
|
-
is supplied the deploy will fail unless --
|
26
|
+
is supplied the deploy will fail unless --ignore-default-branch is used.
|
27
27
|
|
28
28
|
Migrations are run by default with 'rake db:migrate'. A different command can be
|
29
29
|
specified via --migrate "ruby do_migrations.rb". Migrations can also be skipped
|
30
30
|
entirely by using --no-migrate.
|
31
31
|
DESC
|
32
|
-
method_option :
|
32
|
+
method_option :ignore_default_branch, :type => :boolean,
|
33
33
|
:desc => "Force a deploy of the specified branch even if a default is set"
|
34
|
+
method_option :ignore_bad_master, :type => :boolean,
|
35
|
+
:desc => "Force a deploy even if the master is in a bad state"
|
34
36
|
method_option :migrate, :type => :string, :aliases => %w(-m),
|
35
37
|
:default => 'rake db:migrate',
|
36
38
|
:desc => "Run migrations via [MIGRATE], defaults to 'rake db:migrate'; use --no-migrate to avoid running migrations"
|
@@ -45,11 +47,12 @@ module EY
|
|
45
47
|
def deploy
|
46
48
|
app = fetch_app(options[:app])
|
47
49
|
environment = fetch_environment(options[:environment], app)
|
50
|
+
environment.ignore_bad_master = options[:ignore_bad_master]
|
48
51
|
deploy_ref = if options[:app]
|
49
|
-
environment.resolve_branch(options[:ref], options[:
|
52
|
+
environment.resolve_branch(options[:ref], options[:ignore_default_branch]) ||
|
50
53
|
raise(EY::Error, "When specifying the application, you must also specify the ref to deploy\nUsage: ey deploy --app <app name> --ref <branch|tag|ref>")
|
51
54
|
else
|
52
|
-
environment.resolve_branch(options[:ref], options[:
|
55
|
+
environment.resolve_branch(options[:ref], options[:ignore_default_branch]) ||
|
53
56
|
repo.current_branch ||
|
54
57
|
raise(DeployArgumentError)
|
55
58
|
end
|
data/lib/engineyard/error.rb
CHANGED
@@ -68,7 +68,7 @@ module EY
|
|
68
68
|
class BranchMismatch < EY::Error
|
69
69
|
def initialize(default_branch, branch)
|
70
70
|
super %|Your deploy branch is set to "#{default_branch}".\n| +
|
71
|
-
%|If you want to deploy branch "#{branch}", use --
|
71
|
+
%|If you want to deploy branch "#{branch}", use --ignore-default_branch.|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
@@ -1,6 +1,9 @@
|
|
1
1
|
module EY
|
2
2
|
module Model
|
3
|
-
class Environment < ApiStruct.new(:id, :name, :instances, :instances_count, :apps, :app_master, :username, :stack_name, :api)
|
3
|
+
class Environment < ApiStruct.new(:id, :name, :framework_env, :instances, :instances_count, :apps, :app_master, :username, :stack_name, :api)
|
4
|
+
|
5
|
+
attr_accessor :ignore_bad_master
|
6
|
+
|
4
7
|
def self.from_hash(hash)
|
5
8
|
super.tap do |env|
|
6
9
|
env.username = hash['ssh_username']
|
@@ -22,7 +25,7 @@ module EY
|
|
22
25
|
master = app_master
|
23
26
|
if master.nil?
|
24
27
|
raise NoAppMaster.new(name)
|
25
|
-
elsif master.status != "running"
|
28
|
+
elsif !ignore_bad_master && master.status != "running"
|
26
29
|
raise BadAppMasterStatus.new(master.status)
|
27
30
|
end
|
28
31
|
master
|
@@ -3,7 +3,7 @@ require 'escape'
|
|
3
3
|
module EY
|
4
4
|
module Model
|
5
5
|
class Instance < ApiStruct.new(:id, :role, :name, :status, :amazon_id, :public_hostname, :environment)
|
6
|
-
EYSD_VERSION = ENV["EY_DEPLOY_VERSION"] || "0.
|
6
|
+
EYSD_VERSION = ENV["EY_DEPLOY_VERSION"] || "0.8.0"
|
7
7
|
EXIT_STATUS = Hash.new { |h,k| raise EY::Error, "ey-deploy version checker exited with unknown status code #{k}" }
|
8
8
|
EXIT_STATUS.merge!({
|
9
9
|
255 => :ssh_failed,
|
@@ -117,9 +117,11 @@ module EY
|
|
117
117
|
command << instance_tuple.join(',')
|
118
118
|
end
|
119
119
|
|
120
|
+
framework_arg = ['--framework-env', environment.framework_env]
|
121
|
+
|
120
122
|
verbose_arg = verbose ? ['--verbose'] : []
|
121
123
|
|
122
|
-
cmd = Escape.shell_command(start + deploy_args + instance_args + verbose_arg)
|
124
|
+
cmd = Escape.shell_command(start + deploy_args + framework_arg + instance_args + verbose_arg)
|
123
125
|
puts cmd if verbose
|
124
126
|
ssh cmd
|
125
127
|
end
|
data/lib/engineyard/version.rb
CHANGED
@@ -115,6 +115,13 @@ describe "EY::Model::Environment#app_master!" do
|
|
115
115
|
}.should raise_error(EY::BadAppMasterStatus)
|
116
116
|
end
|
117
117
|
|
118
|
+
it "returns the app master if told to ignore the app master being in a non-running state" do
|
119
|
+
env = make_env_with_master("status" => "error")
|
120
|
+
env.ignore_bad_master = true
|
121
|
+
env.app_master!.should_not be_nil
|
122
|
+
env.app_master!.id.should == 44206
|
123
|
+
end
|
124
|
+
|
118
125
|
it "raises an error if the app master is absent" do
|
119
126
|
env = make_env_with_master(nil)
|
120
127
|
lambda {
|
data/spec/ey/deploy_spec.rb
CHANGED
@@ -175,13 +175,13 @@ describe "ey deploy" do
|
|
175
175
|
@ssh_commands.last.should =~ /--branch master/
|
176
176
|
end
|
177
177
|
|
178
|
-
it "complains about a non-default branch without --
|
178
|
+
it "complains about a non-default branch without --ignore-default_branch" do
|
179
179
|
ey "deploy -r current-branch", :expect_failure => true
|
180
180
|
@err.should =~ /deploy branch is set to "master"/
|
181
181
|
end
|
182
182
|
|
183
|
-
it "deploys a non-default branch with --
|
184
|
-
ey "deploy -r current-branch --
|
183
|
+
it "deploys a non-default branch with --ignore-default-branch" do
|
184
|
+
ey "deploy -r current-branch --ignore-default-branch"
|
185
185
|
@ssh_commands.last.should =~ /--branch current-branch/
|
186
186
|
end
|
187
187
|
end
|
data/spec/support/fake_awsm.ru
CHANGED
@@ -155,6 +155,7 @@ private
|
|
155
155
|
"instances_count" => 1,
|
156
156
|
"stack_name" => "nginx_mongrel",
|
157
157
|
"id" => 200,
|
158
|
+
"framework_env" => "production",
|
158
159
|
"app_master" => {
|
159
160
|
"status" => "running",
|
160
161
|
"id" => 27220,
|
@@ -208,6 +209,7 @@ private
|
|
208
209
|
"instances_count" => 1,
|
209
210
|
"stack_name" => "nginx_mongrel",
|
210
211
|
"id" => 200,
|
212
|
+
"framework_env" => "production",
|
211
213
|
"app_master" => _instances.first}],
|
212
214
|
"repository_uri" => git_remote}]
|
213
215
|
end
|
@@ -223,6 +225,7 @@ private
|
|
223
225
|
"instances_count" => 1,
|
224
226
|
"stack_name" => "nginx_mongrel",
|
225
227
|
"id" => 200,
|
228
|
+
"framework_env" => "production",
|
226
229
|
"app_master" => _instances[0]}]
|
227
230
|
end
|
228
231
|
|
@@ -273,6 +276,7 @@ private
|
|
273
276
|
"instances_count" => 1,
|
274
277
|
"stack_name" => "nginx_mongrel",
|
275
278
|
"id" => 200,
|
279
|
+
"framework_env" => "production",
|
276
280
|
"app_master" => {
|
277
281
|
"status" => "running",
|
278
282
|
"id" => 27220,
|
@@ -308,6 +312,7 @@ private
|
|
308
312
|
"instances_count" => 1,
|
309
313
|
"stack_name" => "nginx_mongrel",
|
310
314
|
"id" => 200,
|
315
|
+
"framework_env" => "production",
|
311
316
|
"app_master" => {
|
312
317
|
"status" => "running",
|
313
318
|
"id" => 27220,
|
@@ -379,6 +384,7 @@ private
|
|
379
384
|
"app_master" => keycollector_master,
|
380
385
|
"instances" => [keycollector_master],
|
381
386
|
"id" => 4359,
|
387
|
+
"framework_env" => "production",
|
382
388
|
"stack_name" => "nginx_mongrel"}],
|
383
389
|
}, {
|
384
390
|
"name" => "rails232app",
|
@@ -394,6 +400,7 @@ private
|
|
394
400
|
"name" => "giblets",
|
395
401
|
"app_master" => railsapp_master,
|
396
402
|
"instances" => [railsapp_master],
|
403
|
+
"framework_env" => "production",
|
397
404
|
"id" => 200,
|
398
405
|
"stack_name" => "nginx_unicorn"}],
|
399
406
|
}]
|
@@ -414,6 +421,7 @@ private
|
|
414
421
|
"id" => 6125}],
|
415
422
|
}, {
|
416
423
|
"id" => 4359,
|
424
|
+
"framework_env" => "production",
|
417
425
|
"name" => "keycollector_production",
|
418
426
|
"ssh_username" => "deploy",
|
419
427
|
"stack_name" => "nginx_mongrel",
|
@@ -448,6 +456,7 @@ private
|
|
448
456
|
"apps" => apps,
|
449
457
|
"instances_count" => 1,
|
450
458
|
"stack_name" => "nginx_mongrel",
|
459
|
+
"framework_env" => "production",
|
451
460
|
"id" => 200,
|
452
461
|
"app_master" => {
|
453
462
|
"status" => "running",
|
@@ -469,6 +478,7 @@ private
|
|
469
478
|
"instances_count" => 1,
|
470
479
|
"stack_name" => "nginx_passenger",
|
471
480
|
"id" => 8371,
|
481
|
+
"framework_env" => "production",
|
472
482
|
"app_master" => {
|
473
483
|
"public_hostname" => '127.3.2.1',
|
474
484
|
"status" => "running",
|
@@ -488,6 +498,7 @@ private
|
|
488
498
|
"instances_count" => 1,
|
489
499
|
"stack_name" => "nginx_passenger",
|
490
500
|
"id" => 8371,
|
501
|
+
"framework_env" => "production",
|
491
502
|
"app_master" => {
|
492
503
|
"public_hostname" => '127.44.55.66',
|
493
504
|
"status" => "running",
|
@@ -514,6 +525,7 @@ private
|
|
514
525
|
"instances_count" => 1,
|
515
526
|
"stack_name" => "nginx_mongrel",
|
516
527
|
"id" => 200,
|
528
|
+
"framework_env" => "production",
|
517
529
|
"app_master" => {
|
518
530
|
"public_hostname" => "ec2-174-129-198-124.compute-1.amazonaws.com",
|
519
531
|
"status" => "running",
|
@@ -536,6 +548,7 @@ private
|
|
536
548
|
"instances_count" => 1,
|
537
549
|
"stack_name" => "nginx_passenger",
|
538
550
|
"id" => 8371,
|
551
|
+
"framework_env" => "production",
|
539
552
|
"app_master" => {
|
540
553
|
"public_hostname" => '127.3.2.1',
|
541
554
|
"status" => "running",
|
@@ -559,6 +572,7 @@ private
|
|
559
572
|
"instances_count" => 1,
|
560
573
|
"stack_name" => "nginx_passenger",
|
561
574
|
"id" => 8371,
|
575
|
+
"framework_env" => "production",
|
562
576
|
"app_master" => {
|
563
577
|
"public_hostname" => '127.44.55.66',
|
564
578
|
"status" => "running",
|
@@ -113,32 +113,40 @@ end
|
|
113
113
|
shared_examples_for "it invokes eysd" do
|
114
114
|
include Spec::Helpers::SharedIntegrationTestUtils
|
115
115
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
116
|
+
context "with arguments" do
|
117
|
+
before(:all) do
|
118
|
+
api_scenario "one app, one environment"
|
119
|
+
run_ey({:env => 'giblets', :verbose => true})
|
120
|
+
end
|
121
121
|
|
122
|
-
|
123
|
-
|
124
|
-
|
122
|
+
it "passes --verbose to eysd" do
|
123
|
+
@ssh_commands.should have_command_like(/eysd.*deploy.*--verbose/)
|
124
|
+
end
|
125
125
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
126
|
+
it "passes along instance information to eysd" do
|
127
|
+
instance_args = [
|
128
|
+
Regexp.quote("ec2-174-129-198-124.compute-1.amazonaws.com,app_master"),
|
129
|
+
Regexp.quote("ec2-174-129-142-53.compute-1.amazonaws.com,db_master"),
|
130
|
+
Regexp.quote("ec2-72-44-46-66.compute-1.amazonaws.com,app"),
|
131
|
+
Regexp.quote("ec2-184-73-116-228.compute-1.amazonaws.com,util,fluffy"),
|
132
|
+
]
|
133
|
+
|
134
|
+
# they should all be mentioned
|
135
|
+
instance_args.each do |i|
|
136
|
+
@ssh_commands.last.should =~ /#{i}/
|
137
|
+
end
|
132
138
|
|
133
|
-
|
134
|
-
|
135
|
-
|
139
|
+
# after the option '--instances'
|
140
|
+
@ssh_commands.last.should match(/--instances (#{instance_args.join('|')})/)
|
141
|
+
end
|
142
|
+
|
143
|
+
it "passes the framework environment" do
|
144
|
+
@ssh_commands.last.should match(/--framework-env production/)
|
136
145
|
end
|
137
146
|
|
138
|
-
# after the option '--instances'
|
139
|
-
@ssh_commands.last.should match(/--instances (#{instance_args.join('|')})/)
|
140
147
|
end
|
141
148
|
|
149
|
+
|
142
150
|
context "eysd installation" do
|
143
151
|
before(:all) do
|
144
152
|
api_scenario "one app, one environment"
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 8
|
8
|
+
- 0
|
9
|
+
version: 0.8.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- EY Cloud Team
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-06-
|
17
|
+
date: 2010-06-30 00:00:00 -07:00
|
18
18
|
default_executable: ey
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|