engineyard 0.2.11 → 0.2.12
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/engineyard.rb +4 -3
- data/lib/engineyard/#repo.rb# +24 -0
- data/lib/engineyard/account.rb +32 -11
- data/lib/engineyard/account/api_struct.rb +25 -0
- data/lib/engineyard/account/app.rb +11 -10
- data/lib/engineyard/account/app_master.rb +1 -7
- data/lib/engineyard/account/environment.rb +31 -16
- data/lib/engineyard/account/instance.rb +6 -0
- data/lib/engineyard/account/log.rb +7 -16
- data/lib/engineyard/action/deploy.rb +138 -0
- data/lib/engineyard/action/list_environments.rb +22 -0
- data/lib/engineyard/action/rebuild.rb +31 -0
- data/lib/engineyard/action/show_logs.rb +26 -0
- data/lib/engineyard/action/ssh.rb +19 -0
- data/lib/engineyard/action/upload_recipes.rb +17 -0
- data/lib/engineyard/action/util.rb +47 -0
- data/lib/engineyard/cli.rb +24 -150
- data/lib/engineyard/cli/thor_fixes.rb +26 -0
- data/lib/engineyard/error.rb +48 -0
- data/lib/engineyard/repo.rb +1 -1
- data/lib/engineyard/ruby_ext.rb +9 -0
- data/spec/engineyard/account/api_struct_spec.rb +37 -0
- data/spec/engineyard/account/environment_spec.rb +20 -0
- data/spec/engineyard/account_spec.rb +18 -0
- data/spec/engineyard/cli_spec.rb +3 -3
- data/spec/ey/deploy_spec.rb +166 -28
- data/spec/ey/ey_spec.rb +3 -3
- data/spec/ey/list_environments_spec.rb +16 -0
- data/spec/ey/logs_spec.rb +2 -17
- data/spec/ey/rebuild_spec.rb +25 -0
- data/spec/ey/ssh_spec.rb +24 -0
- data/spec/ey/upload_recipes_spec.rb +21 -0
- data/spec/spec_helper.rb +32 -0
- data/spec/support/fake_awsm.ru +25 -1
- data/spec/support/helpers.rb +72 -7
- metadata +44 -56
- data/lib/engineyard/cli/error.rb +0 -44
- data/spec/spec.opts +0 -2
data/spec/support/fake_awsm.ru
CHANGED
@@ -40,6 +40,14 @@ class FakeAwsm < Sinatra::Base
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
put "/git_remote" do
|
44
|
+
FindableGitRemote.remote = if (!params[:remote] || params[:remote].empty?)
|
45
|
+
nil
|
46
|
+
else
|
47
|
+
params[:remote]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
43
51
|
get "/api/v2/apps" do
|
44
52
|
{"apps" => @@scenario.apps}.to_json
|
45
53
|
end
|
@@ -52,6 +60,14 @@ class FakeAwsm < Sinatra::Base
|
|
52
60
|
{"logs" => @@scenario.logs(params[:env_id])}.to_json
|
53
61
|
end
|
54
62
|
|
63
|
+
post "/api/v2/environments/:env_id/recipes" do
|
64
|
+
{}.to_json
|
65
|
+
end
|
66
|
+
|
67
|
+
put "/api/v2/environments/:env_id/rebuild" do
|
68
|
+
{}.to_json
|
69
|
+
end
|
70
|
+
|
55
71
|
post "/api/v2/authenticate" do
|
56
72
|
if valid_user?
|
57
73
|
{"api_token" => "deadbeef", "ok" => true}.to_json
|
@@ -69,11 +85,19 @@ private
|
|
69
85
|
end
|
70
86
|
|
71
87
|
module FindableGitRemote
|
88
|
+
class << self
|
89
|
+
attr_accessor :remote
|
90
|
+
end
|
91
|
+
|
92
|
+
def git_remote
|
93
|
+
FindableGitRemote.remote || local_git_remote
|
94
|
+
end
|
95
|
+
|
72
96
|
# Since we have to find something in `git remote -v` that
|
73
97
|
# corresponds to an app in cloud.ey in order to do anything, we
|
74
98
|
# simulate this by faking out the API to have whatever git
|
75
99
|
# remote we'll find anyway.
|
76
|
-
def
|
100
|
+
def local_git_remote
|
77
101
|
remotes = []
|
78
102
|
`git remote -v`.each_line do |line|
|
79
103
|
parts = line.split(/\t/)
|
data/spec/support/helpers.rb
CHANGED
@@ -1,21 +1,59 @@
|
|
1
1
|
require 'ey_merkin'
|
2
2
|
require "rest_client"
|
3
|
+
require 'open4'
|
3
4
|
|
4
5
|
module Spec
|
5
6
|
module Helpers
|
6
|
-
|
7
|
+
class UnexpectedExit < StandardError
|
8
|
+
def initialize(stdout, stderr)
|
9
|
+
@stdout, @stderr = stdout, stderr
|
10
|
+
end
|
11
|
+
|
12
|
+
def message
|
13
|
+
"Exited with an unexpected exit code\n---STDOUT---\n#{@stdout}\n---STDERR---\n#{@stderr}\n"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
NonzeroExitStatus = Class.new(UnexpectedExit)
|
17
|
+
ZeroExitStatus = Class.new(UnexpectedExit)
|
18
|
+
|
19
|
+
def ey(cmd = nil, options = {}, &block)
|
7
20
|
require "open3"
|
8
21
|
hide_err = options.delete(:hide_err)
|
9
|
-
|
22
|
+
path_prepends = options.delete(:prepend_to_path)
|
23
|
+
|
24
|
+
ey_env = {
|
25
|
+
'DEBUG' => options[:debug].to_s
|
26
|
+
}
|
27
|
+
|
28
|
+
if path_prepends
|
29
|
+
tempdir = File.join(Dir.tmpdir, "ey_test_cmds_#{Time.now.tv_sec}#{Time.now.tv_usec}_#{$$}")
|
30
|
+
Dir.mkdir(tempdir)
|
31
|
+
path_prepends.each do |name, contents|
|
32
|
+
File.open(File.join(tempdir, name), 'w') do |f|
|
33
|
+
f.write(contents)
|
34
|
+
f.chmod(0755)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
ey_env['PATH'] = tempdir + ':' + ENV['PATH']
|
39
|
+
end
|
10
40
|
|
11
|
-
args = options.map { |k,v| "--#{k} #{v}"}.join(" ")
|
12
41
|
eybin = File.expand_path('../bundled_ey', __FILE__)
|
13
42
|
|
14
|
-
|
43
|
+
with_env(ey_env) do
|
44
|
+
exit_status = Open4::open4("#{eybin} #{cmd}") do |pid, stdin, stdout, stderr|
|
45
|
+
block.call(stdin) if block
|
46
|
+
@err = stderr.read_available_bytes
|
47
|
+
@out = stdout.read_available_bytes
|
48
|
+
end
|
49
|
+
|
50
|
+
if !exit_status.success? && !options[:expect_failure]
|
51
|
+
raise NonzeroExitStatus.new(@out, @err)
|
52
|
+
elsif exit_status.success? && options[:expect_failure]
|
53
|
+
raise ZeroExitStatus.new(@out, @err)
|
54
|
+
end
|
55
|
+
end
|
15
56
|
|
16
|
-
yield @in if block_given?
|
17
|
-
@err = @err.read_available_bytes
|
18
|
-
@out = @out.read_available_bytes
|
19
57
|
@ssh_commands = @out.split(/\n/).find_all do |line|
|
20
58
|
line =~ /^ssh/
|
21
59
|
end.map do |line|
|
@@ -31,6 +69,11 @@ module Spec
|
|
31
69
|
raise "Setting scenario failed: #{response.inspect}" unless response.code == 200
|
32
70
|
end
|
33
71
|
|
72
|
+
def api_git_remote(remote)
|
73
|
+
response = ::RestClient.put(EY.fake_awsm + '/git_remote', {"remote" => remote}, {})
|
74
|
+
raise "Setting git remote failed: #{response.inspect}" unless response.code == 200
|
75
|
+
end
|
76
|
+
|
34
77
|
def read_yaml(file="ey.yml")
|
35
78
|
YAML.load_file(File.expand_path(file))
|
36
79
|
end
|
@@ -38,6 +81,28 @@ module Spec
|
|
38
81
|
def write_yaml(data, file = "ey.yml")
|
39
82
|
File.open(file, "w"){|f| YAML.dump(data, f) }
|
40
83
|
end
|
84
|
+
|
85
|
+
def with_env(new_env_vars)
|
86
|
+
raise ArgumentError, "with_env takes a block" unless block_given?
|
87
|
+
old_env_vars = {}
|
88
|
+
new_env_vars.each do |k, v|
|
89
|
+
if ENV.has_key?(k)
|
90
|
+
old_env_vars[k] = ENV[k]
|
91
|
+
end
|
92
|
+
ENV[k] = v
|
93
|
+
end
|
94
|
+
|
95
|
+
retval = yield
|
96
|
+
|
97
|
+
new_env_vars.keys.each do |k|
|
98
|
+
if old_env_vars.has_key?(k)
|
99
|
+
ENV[k] = old_env_vars[k]
|
100
|
+
else
|
101
|
+
ENV.delete(k)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
retval
|
105
|
+
end
|
41
106
|
end
|
42
107
|
end
|
43
108
|
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: engineyard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 1
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
8
|
+
- 12
|
9
|
+
version: 0.2.12
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- EY Cloud Team
|
@@ -15,80 +14,70 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-
|
17
|
+
date: 2010-05-07 00:00:00 -07:00
|
19
18
|
default_executable: ey
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
|
-
|
23
|
-
|
21
|
+
prerelease: false
|
22
|
+
name: termios
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
hash: 3
|
28
27
|
segments:
|
29
28
|
- 0
|
30
29
|
version: "0"
|
31
|
-
name: termios
|
32
|
-
requirement: *id001
|
33
|
-
prerelease: false
|
34
30
|
type: :runtime
|
31
|
+
version_requirements: *id001
|
35
32
|
- !ruby/object:Gem::Dependency
|
36
|
-
|
37
|
-
|
33
|
+
prerelease: false
|
34
|
+
name: highline
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
36
|
requirements:
|
39
37
|
- - ">="
|
40
38
|
- !ruby/object:Gem::Version
|
41
|
-
hash: 3
|
42
39
|
segments:
|
43
40
|
- 0
|
44
41
|
version: "0"
|
45
|
-
name: highline
|
46
|
-
requirement: *id002
|
47
|
-
prerelease: false
|
48
42
|
type: :runtime
|
43
|
+
version_requirements: *id002
|
49
44
|
- !ruby/object:Gem::Dependency
|
50
|
-
|
51
|
-
|
45
|
+
prerelease: false
|
46
|
+
name: thor
|
47
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
48
|
requirements:
|
53
49
|
- - ">="
|
54
50
|
- !ruby/object:Gem::Version
|
55
|
-
hash: 3
|
56
51
|
segments:
|
57
52
|
- 0
|
58
53
|
version: "0"
|
59
|
-
name: thor
|
60
|
-
requirement: *id003
|
61
|
-
prerelease: false
|
62
54
|
type: :runtime
|
55
|
+
version_requirements: *id003
|
63
56
|
- !ruby/object:Gem::Dependency
|
64
|
-
|
65
|
-
|
57
|
+
prerelease: false
|
58
|
+
name: json
|
59
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
60
|
requirements:
|
67
61
|
- - ">="
|
68
62
|
- !ruby/object:Gem::Version
|
69
|
-
hash: 3
|
70
63
|
segments:
|
71
64
|
- 0
|
72
65
|
version: "0"
|
73
|
-
name: json
|
74
|
-
requirement: *id004
|
75
|
-
prerelease: false
|
76
66
|
type: :runtime
|
67
|
+
version_requirements: *id004
|
77
68
|
- !ruby/object:Gem::Dependency
|
78
|
-
|
79
|
-
|
69
|
+
prerelease: false
|
70
|
+
name: rest-client
|
71
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
80
72
|
requirements:
|
81
73
|
- - ~>
|
82
74
|
- !ruby/object:Gem::Version
|
83
|
-
hash: 7
|
84
75
|
segments:
|
85
76
|
- 1
|
86
77
|
- 4
|
87
78
|
version: "1.4"
|
88
|
-
name: rest-client
|
89
|
-
requirement: *id005
|
90
|
-
prerelease: false
|
91
79
|
type: :runtime
|
80
|
+
version_requirements: *id005
|
92
81
|
description: This gem allows you to deploy your rails application to the Engine Yard cloud directly from the command line.
|
93
82
|
email: cloud@engineyard.com
|
94
83
|
executables:
|
@@ -99,36 +88,33 @@ extra_rdoc_files: []
|
|
99
88
|
|
100
89
|
files:
|
101
90
|
- bin/ey
|
91
|
+
- lib/engineyard/#repo.rb#
|
92
|
+
- lib/engineyard/account/api_struct.rb
|
102
93
|
- lib/engineyard/account/app.rb
|
103
94
|
- lib/engineyard/account/app_master.rb
|
104
95
|
- lib/engineyard/account/environment.rb
|
96
|
+
- lib/engineyard/account/instance.rb
|
105
97
|
- lib/engineyard/account/log.rb
|
106
98
|
- lib/engineyard/account.rb
|
99
|
+
- lib/engineyard/action/deploy.rb
|
100
|
+
- lib/engineyard/action/list_environments.rb
|
101
|
+
- lib/engineyard/action/rebuild.rb
|
102
|
+
- lib/engineyard/action/show_logs.rb
|
103
|
+
- lib/engineyard/action/ssh.rb
|
104
|
+
- lib/engineyard/action/upload_recipes.rb
|
105
|
+
- lib/engineyard/action/util.rb
|
107
106
|
- lib/engineyard/api.rb
|
108
107
|
- lib/engineyard/cli/api.rb
|
109
|
-
- lib/engineyard/cli/
|
108
|
+
- lib/engineyard/cli/thor_fixes.rb
|
110
109
|
- lib/engineyard/cli/ui.rb
|
111
110
|
- lib/engineyard/cli.rb
|
112
111
|
- lib/engineyard/config.rb
|
112
|
+
- lib/engineyard/error.rb
|
113
113
|
- lib/engineyard/repo.rb
|
114
|
+
- lib/engineyard/ruby_ext.rb
|
114
115
|
- lib/engineyard.rb
|
115
116
|
- LICENSE
|
116
117
|
- README.rdoc
|
117
|
-
- spec/engineyard/api_spec.rb
|
118
|
-
- spec/engineyard/cli/api_spec.rb
|
119
|
-
- spec/engineyard/cli_spec.rb
|
120
|
-
- spec/engineyard/config_spec.rb
|
121
|
-
- spec/engineyard/repo_spec.rb
|
122
|
-
- spec/engineyard_spec.rb
|
123
|
-
- spec/ey/deploy_spec.rb
|
124
|
-
- spec/ey/ey_spec.rb
|
125
|
-
- spec/ey/logs_spec.rb
|
126
|
-
- spec/spec.opts
|
127
|
-
- spec/spec_helper.rb
|
128
|
-
- spec/support/bundled_ey
|
129
|
-
- spec/support/fake_awsm.ru
|
130
|
-
- spec/support/helpers.rb
|
131
|
-
- spec/support/ruby_ext.rb
|
132
118
|
has_rdoc: true
|
133
119
|
homepage: http://engineyard.com
|
134
120
|
licenses: []
|
@@ -139,31 +125,30 @@ rdoc_options: []
|
|
139
125
|
require_paths:
|
140
126
|
- lib
|
141
127
|
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
-
none: false
|
143
128
|
requirements:
|
144
129
|
- - ">="
|
145
130
|
- !ruby/object:Gem::Version
|
146
|
-
hash: 3
|
147
131
|
segments:
|
148
132
|
- 0
|
149
133
|
version: "0"
|
150
134
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
-
none: false
|
152
135
|
requirements:
|
153
136
|
- - ">="
|
154
137
|
- !ruby/object:Gem::Version
|
155
|
-
hash: 3
|
156
138
|
segments:
|
157
139
|
- 0
|
158
140
|
version: "0"
|
159
141
|
requirements: []
|
160
142
|
|
161
143
|
rubyforge_project:
|
162
|
-
rubygems_version: 1.3.
|
144
|
+
rubygems_version: 1.3.6
|
163
145
|
signing_key:
|
164
146
|
specification_version: 3
|
165
147
|
summary: Command-line deployment for the Engine Yard cloud
|
166
148
|
test_files:
|
149
|
+
- spec/engineyard/account/api_struct_spec.rb
|
150
|
+
- spec/engineyard/account/environment_spec.rb
|
151
|
+
- spec/engineyard/account_spec.rb
|
167
152
|
- spec/engineyard/api_spec.rb
|
168
153
|
- spec/engineyard/cli/api_spec.rb
|
169
154
|
- spec/engineyard/cli_spec.rb
|
@@ -172,8 +157,11 @@ test_files:
|
|
172
157
|
- spec/engineyard_spec.rb
|
173
158
|
- spec/ey/deploy_spec.rb
|
174
159
|
- spec/ey/ey_spec.rb
|
160
|
+
- spec/ey/list_environments_spec.rb
|
175
161
|
- spec/ey/logs_spec.rb
|
176
|
-
- spec/
|
162
|
+
- spec/ey/rebuild_spec.rb
|
163
|
+
- spec/ey/ssh_spec.rb
|
164
|
+
- spec/ey/upload_recipes_spec.rb
|
177
165
|
- spec/spec_helper.rb
|
178
166
|
- spec/support/bundled_ey
|
179
167
|
- spec/support/fake_awsm.ru
|
data/lib/engineyard/cli/error.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
module EY
|
2
|
-
class CLI < Thor
|
3
|
-
class NoAppError < EY::Error
|
4
|
-
def initialize(repo)
|
5
|
-
@repo = repo
|
6
|
-
end
|
7
|
-
|
8
|
-
def message
|
9
|
-
error = [%|There is no application configured for any of the following remotes:|]
|
10
|
-
@repo.urls.each{|url| error << %|\t#{url}| }
|
11
|
-
error << %|You can add this application at #{EY.config.endpoint}|
|
12
|
-
error.join("\n")
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class EnvironmentError < EY::Error
|
17
|
-
end
|
18
|
-
|
19
|
-
class NoEnvironmentError < EnvironmentError
|
20
|
-
def message
|
21
|
-
"No environment named '#{env_name}'\nYou can create one at #{EY.config.endpoint}"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
class BranchMismatch < EY::Error
|
26
|
-
def initialize(default_branch, branch)
|
27
|
-
super(nil)
|
28
|
-
@default_branch, @branch = default_branch, branch
|
29
|
-
end
|
30
|
-
|
31
|
-
def message
|
32
|
-
%|Your deploy branch is set to "#{@default_branch}".\n| +
|
33
|
-
%|If you want to deploy branch "#{@branch}", use --force.|
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
class DeployArgumentError < EY::Error
|
38
|
-
def message
|
39
|
-
%|"deploy" was called incorrectly. Call as "deploy [ENVIRONMENT] [BRANCH]"\n| +
|
40
|
-
%|You can set default environments and branches in ey.yml|
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
data/spec/spec.opts
DELETED