paratrooper 3.0.0.beta3 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +15 -15
- data/lib/paratrooper/heroku_wrapper.rb +27 -16
- data/lib/paratrooper/version.rb +1 -1
- data/paratrooper.gemspec +1 -1
- data/spec/paratrooper/heroku_wrapper_spec.rb +56 -15
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec0cd33678d37387bbfa8998b12b3b6a33e1cf06
|
4
|
+
data.tar.gz: 47667f7cb489b49eb5aec4fa9d2dac06c18590a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b3977cf28e03eaa58661950e02ad15baa9c40638835b1881944fac32bd31a0251aaa09077cc9ed137ccd08e0d378d2f2b8f576e0ce70ee1ec28aebe22448b31
|
7
|
+
data.tar.gz: 0ed7a25f8aef3fbff257184625170a167c59c9462076bf342610354e62bd169b68724135e81e28cf99e80faa036f35651fb10b3c9ce6fff3cbe11681b0bc98c7
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -39,8 +39,8 @@ Paratrooper.deploy('amazing-app')
|
|
39
39
|
You can also provide a tag:
|
40
40
|
|
41
41
|
```ruby
|
42
|
-
Paratrooper.deploy('amazing-app') do |
|
43
|
-
|
42
|
+
Paratrooper.deploy('amazing-app') do |config|
|
43
|
+
config.tag = 'staging'
|
44
44
|
end
|
45
45
|
```
|
46
46
|
|
@@ -51,8 +51,8 @@ You can authenticate your Heroku account in a few ways:
|
|
51
51
|
* Provide an API Key
|
52
52
|
|
53
53
|
```ruby
|
54
|
-
Paratrooper.deploy('app') do |
|
55
|
-
|
54
|
+
Paratrooper.deploy('app') do |config|
|
55
|
+
config.api_key = 'API_KEY'
|
56
56
|
end
|
57
57
|
```
|
58
58
|
|
@@ -76,16 +76,16 @@ This method works via a local Netrc file handled via the [Heroku Toolbelt][] and
|
|
76
76
|
If you use multiple SSH keys for managing multiple accounts, for example in your `.ssh/config`, you can set the `deployment_host` option:
|
77
77
|
|
78
78
|
```ruby
|
79
|
-
Paratrooper.deploy('amazing-app') do |
|
80
|
-
|
79
|
+
Paratrooper.deploy('amazing-app') do |config|
|
80
|
+
config.deployment_host = 'HOST'
|
81
81
|
end
|
82
82
|
```
|
83
83
|
|
84
84
|
This also works if you're using the [heroku-accounts](https://github.com/ddollar/heroku-accounts) plugin:
|
85
85
|
|
86
86
|
```ruby
|
87
|
-
Paratrooper.deploy('app') do |
|
88
|
-
|
87
|
+
Paratrooper.deploy('app') do |config|
|
88
|
+
config.deployment_host: 'heroku.ACCOUNT_NAME'
|
89
89
|
end
|
90
90
|
```
|
91
91
|
|
@@ -149,13 +149,13 @@ to disable your application monitoring.
|
|
149
149
|
namespace :deploy do
|
150
150
|
desc 'Deploy app in production environment'
|
151
151
|
task :production do
|
152
|
-
Paratrooper.deploy("amazing-production-app") do |
|
153
|
-
|
152
|
+
Paratrooper.deploy("amazing-production-app") do |config|
|
153
|
+
config.add_callback(:before_setup) do |output|
|
154
154
|
output.display("Totally going to turn off newrelic")
|
155
155
|
system %Q[curl https://rpm.newrelic.com/accounts/ACCOUNT_ID/applications/APPLICATION_ID/ping_targets/disable -X POST -H "X-Api-Key: API_KEY"]
|
156
156
|
end
|
157
157
|
|
158
|
-
|
158
|
+
config.add_callback(:after_teardown) do |output|
|
159
159
|
system %Q[curl https://rpm.newrelic.com/accounts/ACCOUNT_ID/applications/APPLICATION_ID/ping_targets/enable -X POST -H "X-Api-Key: API_KEY"]
|
160
160
|
output.display("Aaaannnd we're back")
|
161
161
|
end
|
@@ -172,11 +172,11 @@ Or maybe you just want to run a rake task on your application. Since this task m
|
|
172
172
|
namespace :deploy do
|
173
173
|
desc 'Deploy app in production environment'
|
174
174
|
task :production do
|
175
|
-
Paratrooper.deploy("amazing-production-app") do |
|
176
|
-
|
177
|
-
|
175
|
+
Paratrooper.deploy("amazing-production-app") do |config|
|
176
|
+
config.maintenance = true
|
177
|
+
config.add_callback(:after_teardown) do |output|
|
178
178
|
output.display("Running some task that needs to run")
|
179
|
-
|
179
|
+
config.add_remote_task("rake some:task:to:run")
|
180
180
|
end
|
181
181
|
end
|
182
182
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'platform-api'
|
2
2
|
require 'rendezvous'
|
3
3
|
require 'paratrooper/local_api_key_extractor'
|
4
4
|
require 'paratrooper/error'
|
@@ -18,45 +18,56 @@ module Paratrooper
|
|
18
18
|
@app_name = app_name
|
19
19
|
@key_extractor = options[:key_extractor] || LocalApiKeyExtractor
|
20
20
|
@api_key = options[:api_key] || key_extractor.get_credentials
|
21
|
-
@heroku_api = options[:heroku_api] ||
|
21
|
+
@heroku_api = options[:heroku_api] || PlatformAPI.connect_oauth(api_key)
|
22
22
|
@rendezvous = options[:rendezvous] || Rendezvous
|
23
23
|
end
|
24
24
|
|
25
25
|
def app_restart
|
26
|
-
client(:
|
26
|
+
client(:dyno, :restart_all, app_name)
|
27
27
|
end
|
28
28
|
|
29
29
|
def app_maintenance_off
|
30
|
-
|
30
|
+
client(:app, :update, app_name, 'maintenance' => 'false')
|
31
31
|
end
|
32
32
|
|
33
33
|
def app_maintenance_on
|
34
|
-
|
34
|
+
client(:app, :update, app_name, 'maintenance' => 'true')
|
35
|
+
end
|
36
|
+
|
37
|
+
def releases
|
38
|
+
@releases ||= client(:release, :list, app_name)
|
35
39
|
end
|
36
40
|
|
37
41
|
def run_migrations
|
38
42
|
run_task('rake db:migrate')
|
39
43
|
end
|
40
44
|
|
41
|
-
def run_task(
|
42
|
-
|
43
|
-
|
45
|
+
def run_task(task)
|
46
|
+
payload = { 'command' => task, 'attach' => 'true' }
|
47
|
+
data = client(:dyno, :create, app_name, payload)
|
48
|
+
rendezvous.start(url: data['attach_url'])
|
44
49
|
end
|
45
50
|
|
46
51
|
def last_deploy_commit
|
47
|
-
|
48
|
-
|
49
|
-
|
52
|
+
return nil if last_release_with_slug.nil?
|
53
|
+
slug_data = client(:slug, :info, app_name, get_slug_id(last_release_with_slug))
|
54
|
+
slug_data['commit']
|
55
|
+
end
|
56
|
+
|
57
|
+
def last_release_with_slug
|
58
|
+
# releases is an enumerator
|
59
|
+
releases.to_a.reverse.detect { |release| not release['slug'].nil? }
|
50
60
|
end
|
51
61
|
|
52
62
|
private
|
53
|
-
|
54
|
-
|
63
|
+
|
64
|
+
def get_slug_id(release)
|
65
|
+
release["slug"]["id"]
|
55
66
|
end
|
56
67
|
|
57
|
-
def client(method, *args)
|
58
|
-
heroku_api.public_send(method, *args)
|
59
|
-
rescue
|
68
|
+
def client(delegatee, method, *args)
|
69
|
+
heroku_api.public_send(delegatee).public_send(method, *args)
|
70
|
+
rescue Excon::Errors::Forbidden => e
|
60
71
|
raise ErrorNoAccess.new(app_name)
|
61
72
|
end
|
62
73
|
end
|
data/lib/paratrooper/version.rb
CHANGED
data/paratrooper.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |gem|
|
|
22
22
|
gem.add_development_dependency 'rake'
|
23
23
|
gem.add_development_dependency 'rspec', '~> 3.0'
|
24
24
|
gem.add_development_dependency 'pry'
|
25
|
-
gem.add_dependency '
|
25
|
+
gem.add_dependency 'platform-api', '~> 2.0'
|
26
26
|
gem.add_dependency 'rendezvous', '~> 0.1'
|
27
27
|
gem.add_dependency 'netrc', '~> 0.7'
|
28
28
|
gem.add_dependency 'excon', '>= 0.44.4'
|
@@ -45,69 +45,110 @@ describe Paratrooper::HerokuWrapper do
|
|
45
45
|
|
46
46
|
describe '#app_restart' do
|
47
47
|
it "calls down to heroku api" do
|
48
|
-
expect(heroku_api).to
|
48
|
+
expect(heroku_api).to receive_message_chain(:dyno, :restart_all).with(app_name)
|
49
49
|
wrapper.app_restart
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
53
|
describe '#app_maintenance_off' do
|
54
54
|
it "calls down to heroku api" do
|
55
|
-
expect(heroku_api).to
|
55
|
+
expect(heroku_api).to receive_message_chain(:app, :update).with(app_name, 'maintenance' => 'false')
|
56
56
|
wrapper.app_maintenance_off
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
describe '#app_maintenance_on' do
|
61
61
|
it "calls down to heroku api" do
|
62
|
-
expect(heroku_api).to
|
62
|
+
expect(heroku_api).to receive_message_chain(:app, :update).with(app_name, 'maintenance' => 'true')
|
63
63
|
wrapper.app_maintenance_on
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
describe '#run_migrations' do
|
68
68
|
it 'calls into the heroku api' do
|
69
|
-
expect(heroku_api).to
|
69
|
+
expect(heroku_api).to receive_message_chain(:dyno, :create).with(app_name, {'command' => 'rake db:migrate', 'attach' => 'true' }).and_return(Hash.new)
|
70
70
|
wrapper.run_migrations
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'uses waits for db migrations to run using rendezvous' do
|
74
|
-
data = { '
|
75
|
-
allow(heroku_api).to receive_message_chain(:
|
76
|
-
expect(rendezvous).to receive(:start).with(:url => data['
|
74
|
+
data = { 'attach_url' => 'the_url' }
|
75
|
+
allow(heroku_api).to receive_message_chain(:dyno, :create).with(app_name, {'command' => 'rake db:migrate', 'attach' => 'true' }).and_return(data)
|
76
|
+
expect(rendezvous).to receive(:start).with(:url => data['attach_url'])
|
77
77
|
wrapper.run_migrations
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
81
|
describe "#last_deploy_commit" do
|
82
82
|
context "when deploy data is returned" do
|
83
|
-
let(:
|
84
|
-
|
83
|
+
let(:slug_data) do
|
84
|
+
{ 'commit' => 'SHA' }
|
85
|
+
end
|
86
|
+
|
87
|
+
let(:release_data) do
|
88
|
+
[{ 'slug' => { 'id' => '1' } }]
|
85
89
|
end
|
90
|
+
|
86
91
|
it "returns string of last deployed commit" do
|
87
|
-
|
88
|
-
|
92
|
+
slug_info = release_data.first["slug"]["id"]
|
93
|
+
|
94
|
+
allow(heroku_api).to receive_message_chain(:release, :list).and_return(release_data)
|
95
|
+
expect(heroku_api).to receive_message_chain(:slug, :info).with(app_name, slug_info)
|
96
|
+
.and_return(slug_data)
|
89
97
|
expect(wrapper.last_deploy_commit).to eq('SHA')
|
90
98
|
end
|
91
99
|
end
|
92
100
|
|
93
101
|
context "when no deploys have happened yet" do
|
94
102
|
let(:response) do
|
95
|
-
|
103
|
+
Array.new
|
104
|
+
end
|
105
|
+
|
106
|
+
let(:data) do
|
107
|
+
[{ 'slug' => { 'id' => '1' } }]
|
96
108
|
end
|
97
109
|
|
98
110
|
it "returns nil" do
|
99
|
-
|
100
|
-
|
111
|
+
slug_info = data.first["slug"]["id"].to_i
|
112
|
+
|
113
|
+
allow(heroku_api).to receive_message_chain(:release, :list).and_return(response)
|
101
114
|
expect(wrapper.last_deploy_commit).to eq(nil)
|
102
115
|
end
|
103
116
|
end
|
104
117
|
end
|
105
118
|
|
119
|
+
describe '#last_release_with_slug' do
|
120
|
+
let(:releases) do
|
121
|
+
[
|
122
|
+
{ 'slug' => { 'id' => '1' }, 'updated_at' => '1990' },
|
123
|
+
{ 'slug' => { 'id' => '2' }, 'updated_at' => '2015' },
|
124
|
+
{ 'slug' => nil }
|
125
|
+
]
|
126
|
+
end
|
127
|
+
it 'returns the most current release that has a slug attribute' do
|
128
|
+
allow(heroku_api).to receive_message_chain(:release, :list).and_return(releases)
|
129
|
+
expect(wrapper.last_release_with_slug['updated_at']).to eq '2015'
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'returns nil if none of the releases have a slug attribute' do
|
134
|
+
data = [{ 'slug' => nil }]
|
135
|
+
allow(heroku_api).to receive_message_chain(:release, :list).and_return(data)
|
136
|
+
expect(wrapper.last_release_with_slug).to be_nil
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'returns nil if the releases array is empty' do
|
140
|
+
data = []
|
141
|
+
allow(heroku_api).to receive_message_chain(:release, :list).and_return(data)
|
142
|
+
expect(wrapper.last_release_with_slug).to be_nil
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
106
146
|
describe "#run_task" do
|
107
147
|
it 'calls into the heroku api' do
|
108
148
|
task = 'rake some:task:to:run'
|
109
|
-
expect(heroku_api).to
|
149
|
+
expect(heroku_api).to receive_message_chain(:dyno, :create).with(app_name, {'command' => task, 'attach' => 'true' }).and_return(Hash.new)
|
110
150
|
wrapper.run_task(task)
|
111
151
|
end
|
112
152
|
end
|
153
|
+
|
113
154
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paratrooper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Polito
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-06-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -54,19 +54,19 @@ dependencies:
|
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
57
|
+
name: platform-api
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: '0
|
62
|
+
version: '2.0'
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: '0
|
69
|
+
version: '2.0'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: rendezvous
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
@@ -166,12 +166,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
166
166
|
version: 1.9.2
|
167
167
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
168
168
|
requirements:
|
169
|
-
- - "
|
169
|
+
- - ">="
|
170
170
|
- !ruby/object:Gem::Version
|
171
|
-
version:
|
171
|
+
version: '0'
|
172
172
|
requirements: []
|
173
173
|
rubyforge_project:
|
174
|
-
rubygems_version: 2.
|
174
|
+
rubygems_version: 2.6.11
|
175
175
|
signing_key:
|
176
176
|
specification_version: 4
|
177
177
|
summary: Library to create task for deployment to Heroku
|